@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --line: #e2e8f0;
  --line-strong: rgba(148, 163, 184, 0.18);
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

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

.sidebar {
  width: 220px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 24px 16px;
}

.brand {
  margin-bottom: 20px;
}
.brand strong {
  font-size: 18px;
  color: #fff;
  letter-spacing: -0.02em;
}

.nav-group {
  display: grid;
  gap: 8px;
}

.nav-item {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--sidebar-text);
  display: block;
}
.nav-item:hover {
  background: rgba(255,255,255,0.04);
}
.nav-item.active {
  background: rgba(29,78,216,0.16);
  color: #fff;
}

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

.topbar {
  height: 72px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.user-pill-text strong {
  display: block;
  font-size: 13px;
  color: var(--text);
}
.user-pill-text span {
  font-size: 12px;
  color: var(--muted);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.page-body {
  padding: 24px;
  display: grid;
  gap: 22px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.page-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.04em;
}
.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  background: var(--primary);
  color: #fff;
}
.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.card-grid.single-column {
  grid-template-columns: 1fr;
}

.card,
.table-wrap,
.form-panel {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.card {
  padding: 18px;
  display: grid;
  gap: 10px;
}
.card h3 {
  margin: 0;
  font-size: 16px;
}
.card p,
.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.panel-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.panel-head h4 {
  margin: 0;
  font-size: 17px;
}
.panel-head span {
  color: var(--muted);
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
tr:last-child td { border-bottom: none; }

.form-panel {
  padding: 22px;
}
.form-grid {
  display: grid;
  gap: 16px;
}
.form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-section {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}
.form-section h4 {
  margin: 0;
  font-size: 16px;
}
label {
  display: grid;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}
input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(29,78,216,0.38);
}
.alert {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid rgba(185,28,28,.1);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}
.alert-success {
  background: #dcfce7;
  color: #166534;
  border-color: rgba(22,101,52,.1);
}
.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inline-form input {
  min-width: 130px;
}
.cell-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.empty-state {
  padding: 24px;
}
.empty-state h3 {
  margin: 0 0 6px;
  font-size: 18px;
}
.empty-state p {
  margin: 0;
  color: var(--muted);
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.simple-login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
  padding: 28px;
  display: grid;
  gap: 18px;
}
.simple-login-head h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: -0.04em;
}
.simple-login-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.auth-actions {
  display: grid;
  gap: 12px;
}
.full-width { width: 100%; }

@media (max-width: 980px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    padding: 16px;
  }
  .brand {
    margin-bottom: 12px;
  }
  .nav-group {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .nav-item {
    white-space: nowrap;
  }
}
@media (max-width: 720px) {
  html { font-size: 15px; }
  .topbar,
  .page-body {
    padding: 16px;
  }
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding-top: 16px;
    padding-bottom: 16px;
  }
  .topbar-title {
    font-size: 18px;
  }
  .top-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }
  .top-actions form,
  .top-actions .btn {
    width: 100%;
  }
  .user-pill {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }
  .page-header {
    flex-direction: column;
  }
  .page-header h1 {
    font-size: 24px;
  }
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .card-grid,
  .form-grid.two-col {
    grid-template-columns: 1fr;
  }
  .form-panel,
  .card,
  .form-section {
    padding: 16px;
  }
  .button-row {
    display: grid;
    grid-template-columns: 1fr;
  }
  .button-row .btn,
  .button-row a.btn,
  .inline-form .btn {
    width: 100%;
  }
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }
  .inline-form input {
    min-width: 0;
  }
  .responsive-table thead {
    display: none;
  }
  .responsive-table,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }
  .responsive-table tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }
  .responsive-table tr {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
  }
  .responsive-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }
  .responsive-table td:last-child {
    border-bottom: none;
  }
  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .responsive-table td[data-label=""]::before {
    display: none;
  }
  .responsive-table td form {
    margin: 0;
  }
  .simple-login-card {
    padding: 22px 18px;
    border-radius: 18px;
  }
  .simple-login-head h1 {
    font-size: 24px;
  }
}
