:root {
  --navy: #002A41;
  --navy-dark: #003855;
  --blue: #0089D6;
  --blue-hover: #0077BC;
  --blue-dark: #0071B2;
  --ink: #1B2B36;
  --ink-strong: #0B2230;
  --muted: #5A6B76;
  --muted-2: #8B98A1;
  --border: #E0E4E8;
  --border-input: #C9D2D8;
  --row-border: #EEF1F3;
  --thead-bg: #F7F8F9;
  --page-bg: #EDEDED;
  --green: #1B7A3D;
  --green-bg: #DDF2E4;
  --green-border: #A9DCBB;
  --red: #B3261E;
  --red-strong: #8E1F18;
  --red-bg: #FBE4E2;
  --red-border: #EBB5B0;
  --amber: #9A6700;
  --amber-bg: #FDF0D2;
  --amber-border: #E7C56A;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-bg);
  font-family: 'Poppins', sans-serif;
  color: var(--ink);
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); text-decoration: underline; }

input, select, button, textarea { font-family: 'Poppins', sans-serif; }
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

/* ---- layout shell ---- */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 222px; flex-shrink: 0; background: var(--navy);
  display: flex; flex-direction: column;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 16px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo {
  width: 30px; height: 30px; border-radius: 7px; background: var(--blue);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}
.sidebar-brand .name { font-size: 12.5px; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-brand .sub { font-size: 9.5px; color: #7E96A6; letter-spacing: .1em; text-transform: uppercase; }

.sidebar-nav { padding: 14px 0 4px; overflow-y: auto; flex: 1; }
.sidebar-group-label {
  padding: 0 16px 6px; font-size: 9.5px; font-weight: 600; letter-spacing: .12em; color: #5F7B8D;
}
.sidebar-group-label.admin { padding-top: 16px; }
.nav-item {
  display: flex; align-items: center; padding: 8px 14px 8px 13px;
  font-size: 12.5px; font-weight: 500; cursor: pointer; border-left: 3px solid transparent;
  color: #9FB4C2; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav-item.active { border-left-color: var(--blue); background: rgba(0,137,214,.22); color: #fff; }

.sidebar-user {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 9px;
}
.sidebar-user .avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #0E4A6B; color: #BFD8E8;
  display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 600;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who .name { font-size: 11.5px; font-weight: 500; color: #fff; }
.sidebar-user .who .role { font-size: 9.5px; color: #7E96A6; }
.sidebar-user .signout { font-size: 10.5px; color: #7E96A6; cursor: pointer; }
.sidebar-user .signout:hover { color: #fff; }

.main { flex: 1; overflow-y: auto; background: var(--page-bg); }
.page { padding: 22px 26px 60px; max-width: 1240px; }

h1.page-title { margin: 0 0 16px; font-size: 18px; font-weight: 600; color: var(--ink-strong); }
h2.section-title { margin: 0 0 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-strong); }

/* ---- cards / stats ---- */
.card { background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.card-pad { padding: 14px 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; cursor: pointer; text-decoration: none; display: block; color: inherit; }
.stat-card:hover { border-color: var(--blue); text-decoration: none; }
.stat-card.danger { border-color: var(--red-border); }
.stat-card.danger:hover { border-color: var(--red); }
.stat-label { font-size: 11px; font-weight: 500; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 600; color: var(--ink-strong); line-height: 1.3; }
.stat-value.danger { color: var(--red); }
.stat-note { font-size: 10.5px; color: var(--muted-2); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,auto)); gap: 8px 34px; justify-content: start; }
.detail-label { font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted-2); }
.detail-value { font-size: 12.5px; }
.detail-value.strong { font-weight: 600; }
.detail-sub { font-size: 10.5px; color: var(--muted-2); }

/* ---- tables ---- */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  padding: 8px 14px; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); text-align: left; background: var(--thead-bg); border-bottom: 1px solid #E3E7EA; white-space: nowrap;
}
table.grid th.right { text-align: right; }
table.grid td { padding: 9px 14px; font-size: 12.5px; border-bottom: 1px solid var(--row-border); }
table.grid td.right { text-align: right; }
table.grid td.muted { color: var(--muted); }
table.grid tr.clickable { cursor: pointer; }
table.grid tr.clickable:hover { background: #F2F7FB; }
table.grid tfoot td { padding: 11px 14px; background: var(--thead-bg); border-top: 1px solid #E3E7EA; font-weight: 600; }

/* ---- chips ---- */
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 10px;
  font-weight: 600; letter-spacing: .05em; white-space: nowrap;
}
.chip-lg { padding: 3px 10px; font-size: 10.5px; }

/* ---- banners ---- */
.banner {
  display: flex; align-items: center; gap: 10px; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 18px; font-size: 12.5px; flex-wrap: wrap;
}
.banner .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.banner-success { background: var(--green-bg); border: 1px solid var(--green-border); color: #155F30; }
.banner-success .dot { background: var(--green); }
.banner-danger { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red-strong); }
.banner-danger .dot { background: #C2321F; }
.banner-warning { background: var(--amber-bg); border: 1px solid var(--amber-border); color: #6E4E00; }
.banner-empty { background: #fff; border: 1px dashed var(--border-input); border-radius: 8px; padding: 20px; font-size: 12.5px; color: var(--muted-2); text-align: center; }

/* ---- forms / buttons ---- */
.input, select.input {
  padding: 8px 10px; border: 1px solid var(--border-input); border-radius: 6px; font-size: 12px;
  background: #fff; color: var(--ink);
}
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-2); }
label.field .input { font-weight: 400; text-transform: none; letter-spacing: 0; }

.btn {
  border-radius: 6px; padding: 9px 14px; font-size: 12px; font-weight: 600; cursor: pointer; border: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:disabled { cursor: not-allowed; opacity: .6; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-hover); }
.btn-outline { background: #fff; border: 1px solid var(--border-input); color: var(--ink); }
.btn-outline:hover:not(:disabled) { border-color: var(--blue); color: var(--blue-dark); }
.btn-danger-outline { background: #fff; border: 1px solid #E1998F; color: #C2321F; }
.btn-danger-outline:hover { background: var(--red-bg); }
.btn-danger { background: #C2321F; color: #fff; }
.btn-danger:hover { background: #A82817; }
.btn-sm { padding: 5px 12px; font-size: 11.5px; }
.btn-icon { width: 24px; height: 24px; border: 1px solid var(--border-input); background: #fff; border-radius: 5px; cursor: pointer; font-size: 11px; color: var(--muted); padding: 0; }
.btn-icon.danger { color: #C2321F; }
.btn-icon:hover { border-color: var(--blue); color: var(--blue-dark); }
.btn-icon.danger:hover { border-color: #C2321F; background: var(--red-bg); }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar .spacer { margin-left: auto; font-size: 11.5px; color: var(--muted); }

/* ---- login ---- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg,#003855,#002A41 60%); }
.login-card { width: 360px; background: #fff; border-radius: 10px; padding: 32px 32px 28px; box-shadow: 0 12px 40px rgba(0,10,20,.35); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.login-brand .logo { width: 36px; height: 36px; border-radius: 8px; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.login-brand .name { font-size: 14px; font-weight: 600; color: #002A41; line-height: 1.2; }
.login-brand .sub { font-size: 11px; color: #5A6B76; letter-spacing: .08em; text-transform: uppercase; }
.login-field { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; font-weight: 500; color: #42525C; margin-bottom: 12px; }
.login-field input { padding: 10px 12px; border: 1px solid var(--border-input); border-radius: 6px; font-size: 13px; color: var(--ink); }
.login-error { background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red-strong); border-radius: 6px; padding: 8px 12px; font-size: 12px; margin-bottom: 12px; }

/* ---- tabs ---- */
.tabs { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid #DDE2E6; }
.tab { padding: 8px 16px; font-size: 12.5px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; }
.tab.active { border-bottom-color: var(--blue); color: var(--blue-dark); }

/* ---- assignment rows (trip builder) ---- */
.assign-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.assign-stop { width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 600; flex-shrink: 0; }
.load-bar-track { height: 8px; border-radius: 999px; background: #E9EDF0; overflow: hidden; margin-bottom: 6px; }
.load-bar-fill { height: 100%; border-radius: 999px; transition: width .3s, background .3s; }

/* ---- demo panel ---- */
.demo-pill {
  position: fixed; right: 18px; bottom: 18px; display: flex; align-items: center; gap: 8px;
  background: var(--navy); border-radius: 999px; padding: 8px 14px; box-shadow: 0 10px 30px rgba(0,10,20,.35);
  z-index: 50; cursor: pointer; text-decoration: none; color: inherit;
}
.demo-pill:hover { background: var(--navy-dark); text-decoration: none; }
.demo-pill .label { font-size: 10px; font-weight: 600; letter-spacing: .1em; color: #9FB4C2; }
.demo-panel {
  position: fixed; right: 18px; bottom: 18px; width: 272px; background: var(--navy); border-radius: 10px;
  padding: 14px 16px; box-shadow: 0 10px 30px rgba(0,10,20,.35); z-index: 50;
}
.demo-panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.demo-panel-head .label { font-size: 9.5px; font-weight: 600; letter-spacing: .12em; color: #5F7B8D; }
.demo-panel-head a { margin-left: auto; font-size: 10px; color: #5F7B8D; }
.demo-panel-head a:hover { color: #fff; }
.demo-panel-title { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.demo-panel-title a { font-size: 12.5px; font-weight: 600; color: #fff; }
.demo-panel-desc { font-size: 11px; line-height: 1.5; color: #9FB4C2; margin-bottom: 10px; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0B2230; color: #fff;
  border-radius: 8px; padding: 11px 18px; font-size: 12.5px; box-shadow: 0 8px 24px rgba(0,10,20,.3);
  z-index: 60; animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%,8px); } to { opacity: 1; transform: translate(-50%,0); } }

.muted-link { font-size: 11.5px; }
