:root {
  --ink: #12151a;
  --ink-soft: #3a4250;
  --muted: #6b7380;
  --line: rgba(18, 21, 26, 0.1);
  --bg: #f7f8fa;
  --bg-2: #eef1f5;
  --surface: #ffffff;
  --accent: #4f46e5;
  --accent-soft: #e0e7ff;
  --accent-hot: #818cf8;
  --cta: #12151a;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #4338ca;
  --success: #059669;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(18, 21, 26, 0.07);
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --display: "Sora", "DM Sans", system-ui, sans-serif;
  --mono: "Sora", ui-monospace, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    linear-gradient(rgba(18, 21, 26, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18, 21, 26, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 40px 40px, 40px 40px, auto;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card,
.card,
.dialog-card,
.stat,
.table-wrap,
.pack-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(400px, 100%);
  padding: 1.5rem;
  display: grid;
  gap: 0.85rem;
}

.login-card h1,
.panel-head h2,
.card h3,
.dialog-card h3 {
  margin: 0;
  font-family: var(--display);
  letter-spacing: -0.03em;
}

.login-card label,
.settings-form label,
.dialog-card label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--bg);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.nav-btn:focus-visible {
  outline: 3px solid #a5b4fc;
  outline-offset: 2px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button.primary,
.login-card button[type="submit"] {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--cta);
  color: #fff;
  font-weight: 700;
  padding: 0.65rem 1rem;
  transition: background 160ms var(--ease), transform 160ms var(--ease);
}

button.primary:hover,
.login-card button[type="submit"]:hover {
  background: #000;
}

button.ghost,
.logout {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  padding: 0.5rem 0.85rem;
}

button.danger {
  min-height: 40px;
  border: 0;
  border-radius: 12px;
  background: #fee2e2;
  color: var(--danger);
  padding: 0.5rem 0.85rem;
  font-weight: 600;
}

.form-error,
.form-status {
  margin: 0;
  font-size: 0.9rem;
}

.form-error {
  color: var(--danger);
}

.form-status[data-ok="true"] {
  color: var(--success);
}

.form-status[data-ok="false"] {
  color: var(--danger);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--line);
  background: rgba(247, 248, 250, 0.92);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.35rem 0.4rem;
}

.brand .mark {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  background:
    radial-gradient(circle at 30% 30%, #c7d2fe, transparent 45%),
    radial-gradient(circle at 70% 65%, #818cf8, #3730a3 75%);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

.brand strong {
  display: block;
  font-family: var(--display);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
}

.sidebar nav {
  display: grid;
  gap: 0.35rem;
}

.nav-btn {
  text-align: left;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  padding: 0.7rem 0.8rem;
  font-weight: 600;
}

.nav-btn.is-active,
.nav-btn:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.logout {
  margin-top: auto;
}

.content {
  padding: 1.25rem clamp(1rem, 2.5vw, 1.75rem) 2rem;
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.row-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  padding: 1rem;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.stat strong {
  font-family: var(--mono);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
}

.card {
  padding: 1rem;
}

.filters {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-2);
}

tr:last-child td {
  border-bottom: 0;
}

tr[data-open] {
  cursor: pointer;
}

tr[data-open]:hover {
  background: rgba(79, 70, 229, 0.04);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.5rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.new {
  background: #fef3c7;
  color: var(--warn);
}

.badge.processing {
  background: var(--accent-soft);
  color: var(--ok);
}

.badge.done {
  background: #d1fae5;
  color: var(--success);
}

.badge.cancelled {
  background: #fee2e2;
  color: var(--danger);
}

.linkish {
  color: var(--accent);
  word-break: break-all;
}

.empty {
  padding: 1.25rem;
  color: var(--muted);
}

.pack-list {
  display: grid;
  gap: 0.85rem;
}

.pack-card {
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.pack-card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.pack-card-toolbar .ghost {
  min-height: 36px;
  padding: 0.35rem 0.65rem;
}

.danger-btn {
  color: #b91c1c !important;
}

.pack-card .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 0.5rem;
  align-items: end;
}

.metric-row button {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.settings-form {
  display: grid;
  gap: 0.85rem;
  max-width: 420px;
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  max-width: calc(100% - 2rem);
}

dialog::backdrop {
  background: rgba(18, 21, 26, 0.45);
}

.dialog-card {
  width: min(520px, 100%);
  padding: 1rem;
  display: grid;
  gap: 0.8rem;
}

.dialog-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.icon-close {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
}

.dialog-body {
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.dialog-body strong {
  color: var(--ink);
}

.dialog-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

@media (min-width: 900px) {
  .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: 1.4fr 0.8fr 0.8fr;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .logout {
    margin-top: 0;
  }
}
