:root {
  --sidebar-bg: #151a2e;
  --sidebar-bg-alt: #1b2140;
  --sidebar-border: #262c4a;
  --sidebar-text: #9aa3c4;
  --sidebar-text-active: #ffffff;
  --sidebar-active-bg: rgba(255, 255, 255, 0.08);

  --bg: #f4f5f9;
  --card: #ffffff;
  --border: #e3e5ef;
  --border-soft: #edeef5;
  --text: #14172a;
  --muted: #6b7080;
  --accent: #4a5cf0;
  --accent-hover: #3a49d6;
  --accent-soft: #eef0fe;
  --error: #c0281c;
  --error-soft: #fdecea;
  --success: #157a3f;
  --success-soft: #e6f6ec;
  --warn: #92600a;
  --warn-soft: #fdf1dc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 23, 42, 0.04), 0 8px 24px rgba(20, 23, 42, 0.04);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- App shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 22px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7a5cf0);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.brand-name {
  color: var(--sidebar-text-active);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.nav-label {
  color: #5c6491;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 6px 10px;
  margin-top: 6px;
}

.app-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 0.88rem;
  font-weight: 500;
}

.nav-item:hover { background: var(--sidebar-bg-alt); color: var(--sidebar-text-active); }

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
}
.nav-icon svg { width: 100%; height: 100%; stroke: currentColor; stroke-width: 1.6; fill: none; }

.nav-item.disabled {
  color: #4b5178;
  cursor: default;
}
.nav-item.disabled .nav-icon svg { stroke: #4b5178; }

.sidebar-spacer { flex: 1; }

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 12px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 12px;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sidebar-bg-alt);
  color: var(--sidebar-text-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
  border: 1px solid var(--sidebar-border);
}

.user-name { color: var(--sidebar-text-active); font-size: 0.85rem; font-weight: 600; line-height: 1.3; }
.user-role { font-size: 0.75rem; color: var(--sidebar-text); }

.sidebar-link {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.85rem;
  text-align: left;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.sidebar-link:hover { background: var(--sidebar-bg-alt); color: var(--sidebar-text-active); }

/* ---------- Content area ---------- */

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  padding: 32px 40px 60px;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.page-header h1 { margin: 0 0 4px; }
.page-header .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 6px;
}

h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1rem; margin-top: 26px; margin-bottom: 10px; }
.muted { color: var(--muted); }

/* ---------- Buttons ---------- */

.btn, button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.87rem;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: background 0.12s ease;
}
.btn:hover, button:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 400px; margin: 8vh auto; }

.auth-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}

/* ---------- Forms ---------- */

label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.85rem;
  font-weight: 600;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input[type="file"] {
  padding: 8px;
  background: var(--bg);
  border-style: dashed;
}

.error {
  color: var(--error);
  background: var(--error-soft);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ---------- Stat cards ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.12s ease;
}
.stat-card:hover { border-color: var(--accent); }
.stat-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.stat-card .stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-loaded { background: var(--accent); }
.dot-approved { background: #b8790a; }
.dot-released { background: #1c9150; }
.dot-confirmed_paid { background: #0f6b38; }
.dot-all { background: var(--muted); }

/* ---------- Tabs (secondary filter, used on top of table) ---------- */

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  text-transform: capitalize;
}
.tab.active { background: var(--accent); color: white; border-color: var(--accent); }
.tab .count { opacity: 0.7; margin-left: 4px; }

/* ---------- Table ---------- */

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border-soft); font-size: 0.87rem; }
table.list th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; background: #fafbfd; }
table.list tbody tr:hover { background: #fafbff; }
table.list tr:last-child td { border-bottom: none; }
table.list td.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
table.list a.row-link { text-decoration: none; color: var(--accent); font-weight: 600; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

table.detail { margin: 14px 0; }
table.detail th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 16px 6px 0; vertical-align: top; white-space: nowrap; }
table.detail td { padding: 6px 0; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: capitalize;
}
.status-loaded { background: var(--accent-soft); color: var(--accent); }
.status-approved { background: var(--warn-soft); color: var(--warn); }
.status-released { background: var(--success-soft); color: var(--success); }
.status-confirmed_paid { background: var(--success-soft); color: var(--success); }

/* ---------- Timeline ---------- */

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  padding: 10px 0 10px 22px;
  position: relative;
  font-size: 0.87rem;
  border-left: 2px solid var(--border);
  margin-left: 4px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 14px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--card);
}
.timeline li:last-child { border-left-color: transparent; }

.actions-row { display: flex; gap: 8px; margin-top: 20px; }

/* ---------- Misc ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.back-link:hover { color: var(--text); }

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    gap: 10px;
    overflow-x: auto;
  }
  .sidebar-brand { padding: 0; margin-right: 8px; }
  .nav-label { display: none; }
  .app-nav { flex-direction: row; }
  .sidebar-spacer { display: none; }
  .sidebar-footer { flex-direction: row; align-items: center; border-top: none; margin: 0 0 0 auto; padding: 0; }
  .user-chip { padding: 0 8px 0 0; }
  .user-role { display: none; }
  .content { padding: 20px 16px 40px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  table.list { font-size: 0.82rem; }
}
