:root {
  --navy-900: #0f2136;
  --navy-800: #16324a;
  --navy-700: #1c3f5e;
  --accent: #1f8a70;
  --accent-dark: #17705a;
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --border: #e3e7eb;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --danger: #d94b4b;
  --warning: #d99b1f;
  --success: #1f8a70;
}

* { box-sizing: border-box; }

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

a { text-decoration: none; color: inherit; }

/* ---------- Layout ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
  color: #cfe0ea;
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
}

.sidebar .brand {
  padding: 20px 22px;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  letter-spacing: .3px;
}
.sidebar .brand span { color: var(--accent); }

.sidebar nav { padding: 14px 0; }

.sidebar .nav-section {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .08em;
  color: #7d93a3;
  padding: 14px 22px 6px;
}

.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  color: #cfe0ea;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.06); }
.sidebar a.nav-link.active {
  background: rgba(31,138,112,0.18);
  border-left-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.sidebar .nav-icon { width: 18px; text-align: center; opacity: .85; }

.main {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .page-title { font-size: 18px; font-weight: 700; color: var(--navy-900); }
.topbar .user-chip {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; color: var(--text-muted);
}
.topbar .user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--navy-800); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}

.content { padding: 24px 26px 40px; flex: 1; }

/* ---------- Cards / stat tiles ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 22px;
}
.card-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--navy-900);
  margin: 0 0 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}
.stat-tile {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 18px 20px;
}
.stat-tile.tile-danger  { border-left-color: var(--danger); }
.stat-tile.tile-warning { border-left-color: var(--warning); }
.stat-tile.tile-navy    { border-left-color: var(--navy-800); }
.stat-tile .label { font-size: 12.5px; text-transform: uppercase; letter-spacing:.05em; color: var(--text-muted); margin-bottom: 6px; }
.stat-tile .value { font-size: 24px; font-weight: 700; color: var(--navy-900); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: transparent; color: var(--navy-800); border-color: var(--border); }
.btn-outline:hover { background: #f0f2f4; }
.btn-danger { background: #fdecec; color: var(--danger); border-color: #f6d0d0; }
.btn-danger:hover { background: #fbdada; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--navy-900); }
.form-group { margin-bottom: 16px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  background: #fff;
  color: var(--text-main);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31,138,112,0.12);
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 200px; }

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
}
table.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
table.data-table tr:hover td { background: #fafbfc; }
.table-actions { display: flex; gap: 8px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-success { background: #e3f5ef; color: var(--success); }
.badge-danger  { background: #fdecec; color: var(--danger); }
.badge-warning { background: #fdf3de; color: #92700f; }
.badge-secondary { background: #eef0f2; color: #566072; }

/* ---------- Alerts ---------- */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid transparent;
}
.alert-success { background: #e3f5ef; color: #145c4a; border-color: #bfe6d9; }
.alert-danger  { background: #fdecec; color: #922; border-color: #f6d0d0; }

/* ---------- Login page ---------- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
}
.auth-card {
  background: #fff;
  width: 380px;
  padding: 34px 32px;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-card .brand {
  font-size: 21px; font-weight: 800; color: var(--navy-900); margin-bottom: 4px;
}
.auth-card .brand span { color: var(--accent); }
.auth-card .sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 22px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }
.auth-hint { margin-top: 16px; font-size: 12.5px; color: var(--text-muted); text-align:center; }

/* ---------- Misc ---------- */
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
}
