:root {
  --navy-900: #0b2038;
  --petrol-700: #155e78;
  --ocean-600: #1b8cb2;
  --aqua-500: #43c2c5;
  --bg: #f3f7fb;
  --card: #ffffff;
  --text: #14283d;
  --muted: #667a8f;
  --line: #e3ebf3;
  --shadow: 0 12px 32px rgba(12, 28, 45, 0.08);
  --shadow-soft: 0 8px 20px rgba(12, 28, 45, 0.06);
  --radius: 20px;
  --radius-sm: 14px;
  --ok: #207a4a;
  --error: #b63c4d;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at top right, #e9f5fb 0%, var(--bg) 30%);
  color: var(--text);
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}
.app-shell > div { min-width: 0; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--navy-900), #123252 70%, #134364);
  padding: 20px 16px;
  overflow-y: auto;
  z-index: 30;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 6px 20px;
  color: #e8f2fa;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--aqua-500), var(--ocean-600));
  color: #082030;
  font-weight: 800;
}
.sidebar-brand small {
  display: block;
  color: #a7bfd4;
  font-size: 0.78rem;
}
.sidebar-nav { display: grid; gap: 6px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d5e5f2;
  padding: 11px 12px;
  border-radius: 12px;
  transition: all 0.2s ease;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.1); transform: translateX(2px); }
.nav-link.active {
  background: rgba(67, 194, 197, 0.2);
  color: #effbfd;
  box-shadow: inset 0 0 0 1px rgba(153, 241, 244, 0.2);
}
.nav-icon { width: 20px; text-align: center; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7, 17, 28, 0.45);
  z-index: 20;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar h1 {
  margin: 0;
  font-size: clamp(1rem, 1.1vw, 1.25rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--muted);
}
.user-chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: #e7f6fb;
  color: #0e516e;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  width: 38px;
  height: 38px;
}

.main {
  padding: 20px;
  width: 100%;
}
.page-header,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(21, 94, 120, 0.06);
  padding: 18px;
}
.cards,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  grid-column: span 3;
  display: grid;
  gap: 6px;
  min-height: 125px;
}
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-dot {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: linear-gradient(145deg, #e3f8fc, #c8eef5);
  color: #0e536d;
  display: grid;
  place-items: center;
  font-size: 0.92rem;
}
.stat-title { margin: 0; font-size: 0.84rem; color: var(--muted); font-weight: 600; }
.metric { font-size: clamp(1.25rem, 2.1vw, 1.8rem); font-weight: 800; color: #10273f; }
.stat-desc { font-size: 0.82rem; color: #7b8da2; }

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

.btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--ocean-600), var(--aqua-500));
  box-shadow: 0 10px 22px rgba(27, 140, 178, 0.32);
}
.btn-secondary { background: #edf4fa; color: #214f69; border: 1px solid #d6e6f4; }
.btn-danger { background: linear-gradient(135deg, #d45466, #b8394d); color: #fff; }

.alert {
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  margin: 10px 0;
}
.alert-ok { background: #e4f7ec; color: #1d6942; }
.alert-error { background: #fde8eb; color: #842131; }
.badge {
  background: #edf6fb;
  color: #1e5f7f;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}
.form-grid > * { grid-column: span 12; min-width: 0; }
.field label {
  display: block;
  margin-bottom: 6px;
  color: #35526b;
  font-size: 0.87rem;
  font-weight: 700;
}
.field input,
.field select,
.field textarea,
input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid #d5e2ee;
  background: #fff;
  padding: 11px 13px;
  font-size: 0.95rem;
  color: #173247;
}
.field textarea,
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #7bcfe0;
  box-shadow: 0 0 0 4px rgba(67, 194, 197, 0.18);
}

.table-wrap,
.table-card {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(21, 94, 120, 0.08);
  -webkit-overflow-scrolling: touch;
}
table {
  width: 100%;
  min-width: 650px;
  border-collapse: separate;
  border-spacing: 0;
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #ecf1f6;
  white-space: nowrap;
  font-size: 0.9rem;
}
th {
  color: #5b7288;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #f8fbfe;
}
tr:hover td { background: #fafcfe; }

.muted { color: var(--muted); font-size: 0.93rem; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: linear-gradient(145deg, #08213b, #0f3a5c 55%, #1a8cb2);
}
.login-card {
  width: min(460px, 100%);
  background: rgba(255, 255, 255, 0.97);
  border-radius: 24px;
  box-shadow: 0 24px 45px rgba(6, 20, 35, 0.28);
  padding: 26px;
}
.login-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--ocean-600), var(--aqua-500));
  color: #fff;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  font-weight: 800;
}

/* Mobile 320-767 */
@media (max-width: 767px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    width: min(84vw, 290px);
    transition: transform 0.25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .menu-toggle { display: inline-grid; place-items: center; }
  .topbar-user strong { display: none; }
  .main { padding: 14px; }
  .stat-card { grid-column: span 12; }
  .grid-2 { grid-template-columns: 1fr; }
  .btn { min-height: 44px; }
  table { min-width: 560px; }
}

/* Tablet 768-1024 */
@media (min-width: 768px) and (max-width: 1024px) {
  .app-shell { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { padding: 14px 10px; }
  .sidebar-brand > div { display: none; }
  .nav-link { justify-content: center; padding: 11px 9px; }
  .nav-link span:last-child { display: none; }
  .nav-icon { width: auto; }
  .stat-card { grid-column: span 6; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .form-grid > .field-half { grid-column: span 6; }
}

/* Desktop >1024 */
@media (min-width: 1025px) {
  .stat-card { grid-column: span 3; }
  .form-grid > .field-half { grid-column: span 6; }
  .form-grid > .field-third { grid-column: span 4; }
}
