/* ABC Grinding TMS - dark blue sidebar edition */
:root {
  --blue: #2563eb;
  --blue-dark: #0f2f66;
  --blue-deep: #0a1f45;
  --blue-mid: #143b7e;
  --blue-light: #e8effc;
  --navy: #002080;
  --ink: #17233d;
  --muted: #5b6b8c;
  --line: #d6dff0;
  --bg: #f2f5fb;
  --card: #ffffff;
  --danger: #b3261e;
  --radius: 10px;
  --sbw: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}
body.with-sidebar { margin-left: 18px; transition: margin-left .28s cubic-bezier(.4, 0, .2, 1); }
body.with-sidebar.sb-pinned { margin-left: var(--sbw); }

/* left sidebar navigation — hidden by default, slides in when the mouse
   reaches the left edge, slides away when the mouse leaves it */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sbw);
  background: linear-gradient(180deg, var(--blue-deep) 0%, var(--blue-mid) 100%);
  color: #fff;
  display: flex; flex-direction: column;
  box-shadow: 2px 0 10px rgba(4, 16, 40, .25);
  z-index: 50;
  transform: translateX(calc(-100% + 16px));
  /* snappy open (no delay), forgiving close (.35s delay so it doesn't flicker away) */
  transition: transform .28s cubic-bezier(.4, 0, .2, 1) .35s;
  will-change: transform;
}
.sidebar:hover, .sidebar:focus-within { transform: translateX(0); transition-delay: 0s; }
.sidebar::after {
  /* rounded grip pill on the visible edge strip */
  content: ''; position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 46px; border-radius: 4px; background: rgba(255,255,255,.6);
  pointer-events: none; transition: opacity .2s;
}
.sidebar:hover::after { opacity: 0; }

/* pinned: stays open, content shifts over */
.sb-pinned .sidebar { transform: none; transition-delay: 0s; }
.sb-pinned .sidebar::after { content: none; }
.sb-pin {
  position: absolute; top: 16px; right: 12px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3);
  color: #fff; border-radius: 7px; width: 30px; height: 30px; cursor: pointer;
  font-size: 14px; line-height: 1; transition: background .15s, transform .15s;
}
.sb-pin:hover { background: rgba(255,255,255,.28); }
.sb-pinned .sb-pin { background: #fff; color: var(--blue-dark); transform: rotate(45deg); border-color: #fff; }
.sidebar .brand {
  font-size: 19px; font-weight: 700; letter-spacing: .4px;
  padding: 20px 20px 16px; white-space: nowrap;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar .brand small { display: block; font-size: 10.5px; font-weight: 400; opacity: .8; letter-spacing: 1.8px; margin-top: 3px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 10px; overflow-y: auto; }
.sidebar nav a {
  color: #dbe6fb; text-decoration: none; padding: 11px 14px; border-radius: 8px;
  font-weight: 500; font-size: 14.5px; transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.10); color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.18); color: #fff; border-left-color: #6ea8ff; }
.sidebar .sb-foot {
  margin-top: auto; padding: 14px 16px 18px; border-top: 1px solid rgba(255,255,255,.12);
  display: flex; flex-direction: column; gap: 10px;
}
.sidebar .clock { font-variant-numeric: tabular-nums; font-size: 12.5px; opacity: .85; line-height: 1.4; }
.sidebar .sb-user { font-size: 13.5px; opacity: .95; word-break: break-word; }
.sidebar .sb-signout {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35); color: #fff;
  border-radius: 7px; padding: 7px 13px; font: inherit; font-size: 13px; cursor: pointer; width: 100%;
  transition: background .15s;
}
.sidebar .sb-signout:hover { background: rgba(255,255,255,.24); }

@media (max-width: 900px) {
  body.with-sidebar { margin-left: 0; }
  .sidebar { position: sticky; top: 0; width: auto; bottom: auto; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 4px 8px; transform: none; transition: none; }
  .sidebar::after { content: none; }
  .sb-pin { display: none; }
  body.with-sidebar.sb-pinned { margin-left: 0; }
  .sidebar .brand { border-bottom: none; padding: 10px 12px; font-size: 16px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; padding: 4px; }
  .sidebar nav a { border-left: none; padding: 8px 12px; }
  .sidebar .sb-foot { margin-top: 0; margin-left: auto; border-top: none; flex-direction: row; align-items: center; padding: 6px 10px; }
  .sidebar .clock { display: none; }
  .sidebar .sb-signout { width: auto; }
}

/* layout */
.page { max-width: 1280px; margin: 0 auto; padding: 26px 28px 60px; }
.page-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; font-weight: 650; }
.page-head .sub { color: var(--muted); font-size: 14px; }
.page-head .spacer { flex: 1; }

.grid { display: grid; gap: 22px; }
.grid.cols-2 { grid-template-columns: 420px 1fr; }
@media (max-width: 980px) { .grid.cols-2 { grid-template-columns: 1fr !important; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(16, 30, 60, .06);
}
.card .card-head {
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  font-weight: 650; font-size: 15.5px; display: flex; align-items: center; gap: 10px;
  background: var(--blue-light); border-radius: var(--radius) var(--radius) 0 0;
  color: var(--blue-dark);
}
.card .card-body { padding: 20px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--blue-dark); letter-spacing: .2px; }
.field input, .field textarea, .field select {
  border: 1px solid #b9c8e4; border-radius: 7px; padding: 9px 11px;
  font: inherit; font-size: 14.5px; background: #fff; color: var(--ink);
  transition: border-color .15s, box-shadow .15s; width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}
.field input[readonly] { background: #f2f5fb; color: var(--muted); }
.form-row { display: grid; gap: 14px; }
.form-row.c2 { grid-template-columns: 1fr 1fr; }
.form-row.c3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) { .form-row.c2, .form-row.c3, .form-row.c4 { grid-template-columns: 1fr 1fr; } }

.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--blue-dark); }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }

/* buttons */
.btn {
  border: none; border-radius: 8px; padding: 10px 20px; font: inherit; font-size: 14.5px;
  font-weight: 600; cursor: pointer; transition: filter .15s, transform .05s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--blue-dark); border: 1px solid #b9c8e4; }
.btn.ghost:hover { background: var(--blue-light); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #e3b7b4; }
.btn.danger:hover { background: #fdf1f0; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 6px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }

/* tables */
.tablewrap { overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th {
  text-align: left; padding: 11px 14px; background: #fafbfe; color: var(--muted);
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px;
  border-bottom: 2px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #ecf1f9; vertical-align: top; }
table.data tbody tr:hover { background: var(--blue-light); cursor: pointer; }
table.data tbody tr.sel { background: #d7e4fa; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* hour classification grid */
.hours-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 860px) { .hours-grid { grid-template-columns: 1fr 1fr; } }
.hourbox {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fbfcfe;
}
.hourbox label { display: block; font-size: 12px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.hourbox input {
  width: 100%; border: 1px solid #b9c8e4; border-radius: 6px; padding: 7px 9px;
  font: inherit; text-align: right;
}
.hourbox input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, .16); }

/* toolbar / search */
.toolbar { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar input[type=search] {
  border: 1px solid #b9c8e4; border-radius: 7px; padding: 8px 12px; font: inherit; width: 260px; max-width: 100%;
}
.toolbar .count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* messages */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--blue-dark); color: #fff; padding: 12px 22px; border-radius: 9px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); font-size: 14.5px; opacity: 0; pointer-events: none;
  transition: opacity .25s; z-index: 100;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

/* home */
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-top: 10px; }
.home-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 26px 24px;
  text-decoration: none; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 30, 60, .06);
  transition: transform .12s, box-shadow .12s; display: block;
}
.home-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(16, 30, 60, .12); }
.home-card .icon { font-size: 30px; margin-bottom: 10px; }
.home-card h3 { margin: 0 0 6px; font-size: 17px; color: var(--blue-dark); }
.home-card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 26px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 22px; min-width: 160px; }
.stat .n { font-size: 26px; font-weight: 700; color: var(--blue-dark); }
.stat .l { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

/* report (print-friendly) */
.report-page {
  background: #fff; max-width: 1150px; margin: 0 auto; padding: 34px 38px;
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 4px rgba(0,0,0,.08);
  font-family: Arial, sans-serif;
}
.rep-hdr { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; margin-bottom: 18px; }
.rep-box { border: 1.5px solid #222; padding: 8px 12px; font-size: 13px; }
.rep-title { color: #b000b0; font-weight: 700; }
.rep-blue { color: var(--navy); font-weight: 700; }
.rep-red { color: #c00000; font-weight: 700; font-style: italic; }
table.rep { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.rep th { border-top: 2px solid #000; border-bottom: 1.5px solid #000; padding: 6px 6px; text-align: left; }
table.rep td { border: 1px solid #444; padding: 7px 6px; vertical-align: top; }
.rep-totals { display: flex; gap: 26px; align-items: flex-start; margin-top: 26px; flex-wrap: wrap; font-size: 12.5px; }
.rep-totals table { border-collapse: collapse; }
.rep-totals td { border: 1px solid #444; padding: 5px 9px; }
.prep { background: #7d0f7d; color: #fff; font-weight: 700; padding: 5px 10px; font-size: 12px; }
.prep + .prep { background: #9c2b9c; }
@media print {
  .sidebar, .noprint { display: none !important; }
  body, body.with-sidebar { background: #fff; margin: 0; }
  .page { padding: 0; max-width: none; }
  .report-page { border: none; box-shadow: none; padding: 0; }
}

/* searchable customer dropdown */
.combo { position: relative; }
.combo-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 0 0 9px 9px;
  box-shadow: 0 10px 24px rgba(16, 30, 60, .18); max-height: 240px; overflow: auto;
}
.combo-item { padding: 10px 14px; cursor: pointer; font-size: 14px; }
.combo-item:hover { background: var(--blue-light); }
.combo-empty { padding: 14px; color: var(--muted); font-size: 13.5px; text-align: center; }
.combo-empty a { color: var(--blue-dark); font-weight: 600; }

/* view-only accounts */
.viewer .edit-only { display: none !important; }
.viewer .grid.cols-2:has(> .edit-only) { grid-template-columns: 1fr; }

.notadmin .admin-only { display: none !important; }

/* sortable table headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--blue-dark); }
th.sortable .arr { font-size: 11px; }
