/* Group Timesheet — client styles.
   Class names here mirror exactly what app.js emits. Mobile-first, works well
   on a phone (operators capture on-site) and scales up for manager/office. */

:root {
  --brand: #1A4F91;      /* Rescue Rod blue */
  --brand-dark: #143d70;
  --green: #39AA35;      /* accent / approve */
  --green-dark: #2f8f2c;
  --ink: #1a1a2e;
  --muted: #6b7280;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .18);
  --amber: #d97706;
  --red: #b91c1c;
  --blue: #2563eb;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; }

/* ------------------------------- header --------------------------------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
  position: sticky; top: 0; z-index: 20;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.logo-box { display: flex; align-items: center; gap: 10px; }
.logo-divider { width: 1px; height: 34px; background: var(--line); }
.header-title h1 { font-size: 17px; letter-spacing: .5px; color: var(--brand); font-weight: 900; }
.header-title p { margin: 0; font-size: 11.5px; color: var(--muted); }
.header-right { display: flex; align-items: center; }
.user-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef4fc; color: var(--brand-dark);
  border: 1px solid #d6e4f7; border-radius: 999px;
  padding: 7px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.user-chip:hover { background: #e0edfb; }

/* ------------------------------- layout --------------------------------- */
.content { max-width: 940px; margin: 0 auto; padding: 18px 16px 60px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 20px; border-bottom: 1px solid var(--line); background: #fafbfc;
}
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-body { padding: 18px 20px; }

/* --------------------------- fields & inputs ---------------------------- */
.field { margin-bottom: 14px; }
.field > label {
  display: block; font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); margin-bottom: 5px;
}
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #cbd5e1; border-radius: 9px;
  padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(26, 79, 145, .12);
}
input.ro, input[readonly] { background: #f3f4f6; color: var(--muted); }
input[disabled], select[disabled], textarea[disabled] { background: #f3f4f6; color: #9aa1ab; cursor: not-allowed; }
textarea { resize: vertical; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* segmented worked/absent toggle */
.seg { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 9px; overflow: hidden; }
.seg button {
  border: 0; background: #fff; padding: 9px 22px; font: inherit; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.seg button + button { border-left: 1px solid #cbd5e1; }
.seg button.on { background: var(--brand); color: #fff; }

/* time-segment entry blocks */
.entry { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: #fcfcfd; }
.entry-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.entry-head .n { font-weight: 700; font-size: 13px; color: var(--brand-dark); }

/* --------------------------------- buttons ------------------------------ */
button { font-family: inherit; }
.btn-primary, .btn-secondary, .btn-accent {
  border-radius: 9px; padding: 10px 18px; font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: filter .15s, background .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-accent { background: var(--green); color: #fff; }
.btn-accent:hover { filter: brightness(1.07); }
.btn-secondary { background: #fff; color: var(--ink); border-color: #cbd5e1; }
.btn-secondary:hover { background: #f8fafc; }
.btn-primary[disabled], .btn-accent[disabled] { opacity: .6; cursor: default; filter: none; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-bar { display: flex; gap: 10px; margin-top: 16px; }

.btn-add {
  width: 100%; padding: 11px; border: 1px dashed #b6c2d4; border-radius: 9px;
  background: #f8fafc; color: var(--brand-dark); font-weight: 600; cursor: pointer;
}
.btn-add:hover { background: #eef4fc; }
.btn-remove { border: 0; background: none; color: var(--red); font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 2px 4px; }
.btn-clear-sig { margin-top: 8px; border: 0; background: none; color: var(--brand); font-size: 12.5px; font-weight: 600; cursor: pointer; }

/* --------------------------------- tables ------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); background: #fafbfc;
}
tbody td { padding: 11px 16px; border-bottom: 1px solid #f1f3f7; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafc; }
.td-actions { display: flex; gap: 6px; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 30px 16px; }

/* --------------------------------- badges ------------------------------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  background: #e5e7eb; color: #374151;
}
.b-draft     { background: #e5e7eb; color: #4b5563; }
.b-submitted { background: #dbeafe; color: #1d4ed8; }
.b-approved  { background: #dcfce7; color: #15803d; }
.b-amended   { background: #fef3c7; color: #b45309; }
.b-rejected  { background: #fee2e2; color: #b91c1c; }
.b-late      { background: #ffe4d5; color: #c2410c; }
.b-weekend   { background: #ede9fe; color: #6d28d9; }
.b-holiday   { background: #cffafe; color: #0e7490; }
.b-ot        { background: #fef9c3; color: #a16207; }

/* ----------------------------- info / alerts ---------------------------- */
.info, .warn, .alert, .cloud-box {
  border-radius: 10px; padding: 12px 14px; font-size: 13.5px; margin-bottom: 14px;
}
.info { background: #eff6ff; border: 1px solid #dbeafe; color: #1e40af; }
.cloud-box { background: #f0fdf4; border: 1px solid #dcfce7; color: #166534; }
.warn { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert li { margin: 2px 0; }

/* -------------------------------- login --------------------------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 30px 26px;
}
.login-logos { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 18px; }
.login-card h2 { text-align: center; font-size: 20px; color: var(--brand); }
.login-card .tag { text-align: center; color: var(--muted); font-size: 12.5px; margin: 4px 0 20px; }
.login-card .btn-primary { margin-top: 6px; }

/* --------------------------------- tabs --------------------------------- */
.tabs {
  display: flex; gap: 4px; max-width: 940px; margin: 0 auto; padding: 12px 16px 0;
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.tab-btn {
  border: 0; background: none; padding: 10px 16px; font-size: 14px; font-weight: 600;
  color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap;
}
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }

/* filter bar */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 16px; }
.filter-bar .field { margin-bottom: 0; min-width: 130px; }
.filter-bar .btn-primary, .filter-bar .btn-secondary { height: 42px; }

/* --------------------------- signature capture -------------------------- */
.sig-wrapper { position: relative; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; overflow: hidden; }
canvas.sig { display: block; width: 100%; height: 150px; touch-action: none; cursor: crosshair; }
canvas.sig.signed { background: #fff; }
.sig-placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #9ca3af; font-size: 14px; pointer-events: none;
}

/* --------------------------- modal / overlay ---------------------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: none; align-items: center; justify-content: center; padding: 18px; z-index: 50;
}
.overlay.open { display: flex; }
.modal {
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 22px 22px 20px;
}
.modal h3 { font-size: 17px; margin-bottom: 4px; }
.modal .sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f1f3f7; font-size: 13.5px; }
.summary-line span { color: var(--muted); }

.code-pill {
  display: inline-block; font-family: "SF Mono", Consolas, monospace; font-size: 26px; font-weight: 700;
  letter-spacing: 3px; background: #eef4fc; color: var(--brand-dark);
  border: 1px dashed #b6c2d4; border-radius: 10px; padding: 12px 22px;
}

/* --------------------------------- toast -------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 24px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 80; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok   { background: #15803d; }
.toast.err  { background: #b91c1c; }
.toast.info { background: var(--brand); }

/* ------------------------------ responsive ------------------------------ */
@media (max-width: 560px) {
  .row2, .grid { grid-template-columns: 1fr; }
  .header-title p { display: none; }
  .app-header { padding: 10px 14px; }
  .content { padding: 14px 12px 50px; }
  .card-body { padding: 16px 14px; }
}
