:root {
  --brand-navy: #0b1f3a;
  --brand-navy-soft: #143056;
  --brand-teal: #0d9488;
  --brand-teal-dark: #0f766e;
  --brand-teal-light: #14b8a6;
  --brand-sky: #e8f7f5;
  --brand-amber: #f59e0b;
  --brand-rose: #e11d48;
  --brand-slate: #64748b;
  --surface: #f4f7fb;
  --card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(11, 31, 58, 0.08);
  --radius: 16px;
  --sidebar-width: 260px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
  line-height: 1.5;
}

a { color: var(--brand-teal-dark); text-decoration: none; }
a:hover { color: var(--brand-teal); }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--brand-navy) 0%, var(--brand-navy-soft) 100%);
  color: #fff;
  padding: 1.25rem 1rem 2rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .75rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 1rem;
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-teal-light), var(--brand-teal-dark));
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-family: var(--font-display);
}
.brand-text strong {
  display: block; font-family: var(--font-display); font-size: 1.15rem; letter-spacing: .02em;
}
.brand-text span { font-size: .75rem; opacity: .7; }

.nav-section {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  opacity: .55; margin: 1rem .75rem .4rem;
}
.nav-link {
  display: flex; align-items: center; gap: .7rem;
  color: rgba(255,255,255,.82);
  padding: .65rem .85rem;
  border-radius: 12px;
  margin-bottom: .2rem;
  transition: .2s ease;
}
.nav-link:hover, .nav-link.active {
  background: rgba(13, 148, 136, .22);
  color: #fff;
}
.nav-link.active { box-shadow: inset 3px 0 0 var(--brand-teal-light); }
.nav-ico {
  width: 1.25rem; text-align: center; opacity: .9;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: .9rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
  font-family: var(--font-display);
  font-weight: 600;
}
.user-chip {
  display: flex; align-items: center; gap: .75rem;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-teal), var(--brand-navy));
  color: #fff; display: grid; place-items: center; font-weight: 700;
}
.content { padding: 1.5rem; }

.page-hero {
  background:
    radial-gradient(circle at top right, rgba(20,184,166,.25), transparent 35%),
    linear-gradient(135deg, #0b1f3a 0%, #143056 55%, #0f766e 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.page-hero::after {
  content: "";
  position: absolute; right: -40px; top: -40px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.page-hero h2 {
  margin: 0 0 .35rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
}
.page-hero p { margin: 0; opacity: .85; max-width: 48rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(11,31,58,.12); }
.stat-card .label { color: var(--text-muted); font-size: .85rem; }
.stat-card .value {
  font-size: 1.7rem; font-weight: 700; margin-top: .2rem;
  font-family: var(--font-display); color: var(--brand-navy);
}
.stat-card .hint { font-size: .78rem; color: var(--brand-teal-dark); margin-top: .35rem; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.panel-header h3 {
  margin: 0; font-size: 1.05rem; font-family: var(--font-display); font-weight: 600;
}
.panel-body { padding: 1.25rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: none; border-radius: 12px; padding: .6rem 1rem;
  font-weight: 600; font-size: .9rem; cursor: pointer;
  transition: .2s ease; text-decoration: none;
}
.btn-primary { background: var(--brand-teal); color: #fff; }
.btn-primary:hover { background: var(--brand-teal-dark); color: #fff; }
.btn-navy { background: var(--brand-navy); color: #fff; }
.btn-navy:hover { background: var(--brand-navy-soft); color: #fff; }
.btn-outline {
  background: transparent; color: var(--brand-navy);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--brand-teal); color: var(--brand-teal-dark); }
.btn-danger { background: var(--brand-rose); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; border-radius: 10px; }
.btn-light { background: rgba(255,255,255,.15); color: #fff; }
.btn-light:hover { background: rgba(255,255,255,.25); color: #fff; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse;
}
table.data th, table.data td {
  padding: .85rem 1rem; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data th {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); background: #f8fafc; font-weight: 700;
}
table.data tr:hover td { background: #f8fffe; }

.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-muted { background: #e2e8f0; color: #334155; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
.form-group label {
  display: block; margin-bottom: .35rem; font-weight: 600; font-size: .88rem;
}
.form-control, .form-select, textarea.form-control {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .7rem .85rem;
  background: #fff;
  font: inherit;
  transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus, textarea.form-control:focus {
  outline: none;
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 3px rgba(13,148,136,.15);
}

.alert {
  padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 500;
  display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem;
  transition: opacity .2s ease, transform .2s ease;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-info { background: #e0f2fe; color: #075985; }
.alert-close {
  background: transparent; border: 0; font-size: 1.25rem; line-height: 1;
  cursor: pointer; color: inherit; opacity: .7; padding: 0 .15rem;
}
.alert-close:hover { opacity: 1; }
.alert-hide { opacity: 0; transform: translateY(-6px); }

.field-error {
  color: #b91c1c; font-size: .78rem; margin-top: .3rem; font-weight: 500;
}
.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #ef4444;
}

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  flex-wrap: wrap; padding: .85rem 1.25rem; border-top: 1px solid var(--border);
}
.pagination-meta { font-size: .82rem; color: var(--text-muted); }
.pagination-links { display: flex; gap: .35rem; flex-wrap: wrap; }

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  z-index: 40; opacity: 0; transition: opacity .2s ease;
}
.sidebar-backdrop.show {
  display: block; opacity: 1;
}
body.sidebar-open { overflow: hidden; }

.chip-check {
  display: flex; gap: .35rem; align-items: center;
  background: #fff; border: 1px solid var(--border);
  padding: .35rem .6rem; border-radius: 999px;
}

.empty-state {
  text-align: center; padding: 2rem 1rem; color: var(--text-muted);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  background: var(--surface);
}
.auth-visual {
  position: relative;
  background:
    linear-gradient(160deg, rgba(11,31,58,.92), rgba(13,148,136,.75)),
    url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"><path d="M0 40h80M40 0v80" stroke="rgba(255,255,255,.06)" stroke-width="1"/></svg>');
  color: #fff;
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
}
.auth-visual h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.2rem);
  margin: 0 0 .75rem;
  max-width: 12ch;
  line-height: 1.1;
}
.auth-visual p { max-width: 34rem; opacity: .9; font-size: 1.05rem; }
.auth-panel {
  display: grid; place-items: center; padding: 2rem;
}
.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: rise .5s ease;
}
.auth-card h2 {
  font-family: var(--font-display); margin: 0 0 .35rem;
}
.demo-accounts {
  margin-top: 1rem; padding: .9rem; border-radius: 12px; background: var(--brand-sky);
  font-size: .82rem; color: var(--brand-navy);
}
.demo-accounts code { font-weight: 700; }

.toolbar {
  display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.search-input { max-width: 280px; }

.grid-2 {
  display: grid; grid-template-columns: 1.2fr .8fr; gap: 1.25rem;
}

.mobile-toggle {
  display: none;
  background: transparent; border: 1px solid var(--border);
  border-radius: 10px; padding: .4rem .6rem; cursor: pointer;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.fade-in { animation: rise .45s ease; }

table.data tr.is-editing td {
  background: rgba(13, 148, 136, 0.08);
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 50;
    transform: translateX(-105%); transition: transform .25s ease;
    width: min(280px, 85vw);
  }
  .sidebar.open { transform: none; }
  .mobile-toggle { display: inline-flex; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { min-height: 220px; padding: 2rem; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (min-width: 901px) {
  .sidebar-backdrop { display: none !important; }
}
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
}
