/* ============================================================
   BLACK DIAMOND — DAILY DRILLING LOG
   "Corporate Trust" aesthetic: indigo→violet gradients, soft
   colored shadows, Plus Jakarta Sans, slate surfaces, dimensional
   depth. Enterprise-ready yet approachable.
   ============================================================ */

:root {
  /* surfaces & text */
  --bg: #f8fafc;            /* slate-50  */
  --surface: #ffffff;
  --text: #0f172a;          /* slate-900 */
  --text-muted: #64748b;    /* slate-500 */
  --border: #e2e8f0;        /* slate-200 */
  --border-faint: #f1f5f9;  /* slate-100 */

  /* brand */
  --primary: #4f46e5;       /* indigo-600 */
  --primary-dark: #4338ca;  /* indigo-700 */
  --primary-soft: #eef2ff;  /* indigo-50  */
  --secondary: #7c3aed;     /* violet-600 */
  --success: #10b981;       /* emerald-500 */

  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --grad-dark: linear-gradient(135deg, #312e81 0%, #4c1d95 100%);

  /* semantic gantt / category colors (encode meaning — kept distinct) */
  --cat-productive: #10b981; /* emerald */
  --cat-standby: #f59e0b;    /* amber   */
  --cat-mechanical: #f43f5e; /* rose    */
  --cat-downtime: #3b82f6;   /* blue    */

  /* legacy aliases still read by chart code */
  --amber: #4f46e5;
  --ink: #0f172a;

  --font-display: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --r-xl: 16px;
  --r-lg: 12px;
  --r-md: 8px;
  --r-sm: 6px;

  --shadow-soft: 0 4px 20px -2px rgba(79, 70, 229, 0.10);
  --shadow-hover: 0 10px 25px -5px rgba(79, 70, 229, 0.15), 0 8px 10px -6px rgba(79, 70, 229, 0.10);
  --shadow-btn: 0 4px 14px 0 rgba(79, 70, 229, 0.30);
  --glow: 0 0 20px rgba(79, 70, 229, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 40px 16px 120px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* atmospheric background blobs */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  pointer-events: none;
}

body::before {
  width: 460px;
  height: 460px;
  top: -140px;
  left: -120px;
  background: radial-gradient(circle, #c7d2fe, transparent 70%);
}

body::after {
  width: 540px;
  height: 540px;
  bottom: -180px;
  right: -140px;
  background: radial-gradient(circle, #ddd6fe, transparent 70%);
}

.sheet {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-soft);
}

/* ============ MASTHEAD ============ */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 26px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}

.masthead-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.diamond-logo {
  width: 44px;
  height: 44px;
  flex: none;
  background: var(--grad);
  border-radius: 12px;
  transform: rotate(45deg);
  box-shadow: var(--glow), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.masthead h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 4.5vw, 46px);
  line-height: 1;
  letter-spacing: -0.02em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.masthead-sub {
  margin: 6px 0 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.masthead-meta {
  display: flex;
  gap: 8px;
}

.meta-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface);
}

.meta-chip--amber {
  border-color: #c7d2fe;
  color: var(--primary);
  background: var(--primary-soft);
}

/* ============ SECTIONS ============ */

.log-section { border-bottom: 1px solid var(--border); }
.log-section:last-of-type { border-bottom: none; }

.section-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 32px 8px;
  background: transparent;
  color: var(--text);
}

.section-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: var(--grad);
  padding: 5px 10px;
  border-radius: var(--r-md);
  box-shadow: var(--glow);
  min-width: 30px;
  text-align: center;
}

.section-bar h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--text);
}

.bar-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-muted);
  margin-left: 10px;
}

.section-body { padding: 12px 32px 28px; }
.section-body--flush { padding: 8px 0 24px; }

/* ============ FIELDS ============ */

.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px 28px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field--wide { grid-column: 1 / -1; }

.field-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="date"],
.field input[type="email"],
.field input[type="password"] {
  min-width: 0;
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* segmented shift toggle */
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: max-content;
}

.seg-btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 24px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.seg-btn:hover:not(.is-active) { color: var(--text); }
.seg-btn.is-active { background: var(--grad); color: #fff; box-shadow: var(--shadow-btn); }

/* method pills */
.pill-group { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.pill {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.pill:hover { transform: translateY(-1px); border-color: var(--primary); box-shadow: var(--shadow-soft); }
.pill.is-active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-btn); }

.pill-other {
  font-family: var(--font-body);
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 9px 12px;
  min-width: 180px;
}

.pill-other:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); }

/* ============ TABLES ============ */

.log-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.log-table th {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg);
  color: var(--text-muted);
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.log-table td {
  border-bottom: 1px solid var(--border-faint);
  padding: 0;
}

.log-table td input {
  width: 100%;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 11px 12px;
}

.log-table td input:focus { outline: none; background: var(--primary-soft); }
.log-table td input[readonly] { color: var(--text-muted); background: var(--bg); }

.col-idx { width: 44px; }
.col-hours { width: 180px; }
.col-del { width: 40px; }

.row-idx {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
  color: var(--text-muted);
}

.del-row {
  width: 100%;
  font-size: 16px;
  line-height: 1;
  padding: 8px 0;
  background: transparent;
  border: none;
  color: var(--border);
  cursor: pointer;
  transition: color 0.2s ease;
}

.del-row:hover { color: var(--cat-mechanical); }

.log-table tfoot td {
  border-top: 1px solid var(--border);
  padding: 11px 12px;
  background: var(--primary-soft);
}

.tfoot-label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: right;
  color: var(--text-muted);
}

.tfoot-value { font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: var(--primary); }

.add-row {
  margin-top: 14px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: none;
  padding: 9px 18px;
  background: var(--surface);
  border: 1px dashed #c7d2fe;
  color: var(--primary);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.add-row:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); }

/* dense drilling-details table */
.table-scroll { overflow-x: auto; }
.log-table--dense { min-width: 1220px; }
.col-comment { min-width: 160px; }
.log-table--dense th { font-size: 11px; padding: 8px 8px; }
.log-table--dense td input { font-size: 13px; padding: 9px 8px; }
.col-sticky { min-width: 150px; }

/* ============ MATERIALS ============ */

.col-amount { width: 160px; }
.col-unit { width: 150px; }

.unit-select {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  background: transparent;
  border: none;
  padding: 11px 12px;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.unit-select:focus { outline: none; background-color: var(--primary-soft); }

.qty-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px 28px;
}

/* ============ GANTT ============ */

.gantt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 4px 32px 16px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.legend-swatch { width: 12px; height: 12px; border-radius: 3px; transform: rotate(45deg); }

.gantt-scroll { overflow: auto; max-height: 70vh; border-top: 1px solid var(--border); }

.gantt {
  --label-w: 240px;
  --total-w: 60px;
  display: grid;
  grid-template-columns: var(--label-w) repeat(48, minmax(21px, 1fr)) var(--total-w);
  min-width: 1340px;
  user-select: none;
}

/* header row */
.g-corner,
.g-total-head {
  background: var(--text);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 10px;
  display: flex;
  align-items: flex-end;
}

/* freeze panes: corner pinned to both edges, header row pinned to top */
.g-corner { position: sticky; left: 0; top: 0; z-index: 5; }
.g-total-head { position: sticky; top: 0; z-index: 4; justify-content: center; }

.g-hour {
  position: sticky;
  top: 0;
  z-index: 4;
  grid-column: span 2;
  background: var(--text);
  color: #cbd5e1;
  font-family: var(--font-mono);
  font-size: 10.5px;
  padding: 8px 0 6px 4px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
  overflow: hidden;
}

.g-hour--nextday { color: #a5b4fc; }

/* category divider row (background set inline by JS to the category color) */
.g-cat {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  padding: 6px 12px;
  position: sticky;
  left: 0;
  z-index: 3;
}

.g-cat .g-cat-hrs {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
}

/* activity rows */
.g-label {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--surface);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.01em;
  text-transform: none;
  padding: 8px 10px 8px 22px;
  border-bottom: 1px solid var(--border-faint);
  border-right: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.g-label::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 50%;
  width: 6px;
  height: 6px;
  transform: translateY(-50%) rotate(45deg);
  background: var(--row-color, var(--text));
}

.g-cell {
  border-bottom: 1px solid var(--border-faint);
  border-left: 1px solid var(--border-faint); /* half-hour line: faint */
  min-height: 30px;
  cursor: crosshair;
  position: relative;
}

.g-cell--hour { border-left-color: #cbd5e1; } /* hour line: clearly stronger */
.g-cell:hover { background: rgba(79, 70, 229, 0.12); }

.g-cell.is-on { background: var(--row-color); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.3); }
.g-cell.is-on:hover { filter: brightness(1.12); }

.g-row-total {
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-faint);
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
}

.g-row-total.has-hours { color: var(--primary); font-weight: 700; }

/* ============ SUMMARY BAR ============ */

.summary-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 32px;
  background: var(--grad-dark);
  color: #e0e7ff;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  box-shadow: 0 -6px 22px -6px rgba(79, 70, 229, 0.4);
}

.summary-items { display: flex; flex-wrap: wrap; gap: 22px; }

.summary-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c7d2fe;
}

.summary-item .sum-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.summary-item--grand { padding-left: 18px; border-left: 1px solid rgba(255, 255, 255, 0.2); }
.summary-item--grand .sum-val { color: #6ee7b7; }

/* ============ BUTTONS ============ */

.btn-ghost {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  padding: 10px 22px;
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn-ghost:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4); }
.btn-ghost--green { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35); }
.btn-ghost--green:hover:not(:disabled) { box-shadow: 0 8px 20px rgba(16, 185, 129, 0.45); }
.btn-ghost:disabled, .btn-ghost--green:disabled { opacity: 0.55; cursor: default; box-shadow: none; }

/* solid white / emerald buttons for the dark summary bar */
.summary-bar .btn-ghost { background: #fff; color: var(--primary-dark); box-shadow: 0 4px 14px rgba(15, 23, 42, 0.28); }
.summary-bar .btn-ghost:hover:not(:disabled) { background: #f1f5ff; }
.summary-bar .btn-ghost--green { background: linear-gradient(135deg, #34d399, #10b981); color: #fff; }

/* ============ RESPONSIVE ============ */

@media (max-width: 860px) {
  body { padding: 16px 8px 120px; }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .qty-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-body { padding: 12px 14px 24px; }
  .section-bar { padding: 16px 14px 8px; }
  .masthead { padding: 22px 16px; }
  .gantt-legend { padding: 4px 14px 14px; }
}

@media (max-width: 600px) {
  .log-table:not(.log-table--dense) { table-layout: fixed; }
  .col-idx { width: 32px; }
  .col-hours { width: 90px; }
  .col-amount { width: 74px; }
  .col-unit { width: 96px; }
  .col-del { width: 32px; }
  .log-table th { font-size: 11px; padding: 8px 6px; white-space: normal; }
  .log-table td input { font-size: 13px; padding: 9px 6px; }
  .unit-select { font-size: 12px; padding: 9px 4px; background-position: calc(100% - 10px) 50%, calc(100% - 5px) 50%; }
  .tfoot-label { font-size: 11px; }

  .gantt { --label-w: 158px; --total-w: 44px; }
  .g-label { font-size: 11px; padding-left: 18px; }
  .g-cell { min-height: 34px; }

  .summary-bar { padding: 10px 14px; gap: 8px; }
  .summary-items { gap: 6px 14px; }
  .summary-item { font-size: 11px; gap: 5px; }
  .summary-item .sum-val { font-size: 13px; }
  .summary-item--grand { padding-left: 0; border-left: none; }
  .btn-ghost { padding: 8px 16px; font-size: 13px; }
}

@media (max-width: 520px) {
  .field-grid { grid-template-columns: minmax(0, 1fr); }
  .masthead h1 { font-size: 28px; }
  .masthead-sub { font-size: 10px; letter-spacing: 0.14em; }
}

/* ============ CHIPS & BUTTONS (app shell) ============ */

.meta-chip--link {
  color: var(--primary);
  background: var(--surface);
  text-decoration: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
}

.meta-chip--link:hover { border-color: var(--primary); background: var(--primary-soft); }
.meta-chip--green { border-color: #a7f3d0; color: #059669; background: #ecfdf5; }

.btn-outline {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  padding: 9px 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); background: var(--bg); transform: translateY(-1px); }
.btn-outline:disabled { opacity: 0.45; cursor: default; }

.summary-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============ CONTROL BAR (white strip under masthead) ============ */

.control-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.ctrl-spacer { flex: 1; }

.ctrl-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.ctrl-chip--status {
  color: var(--primary);
  border-color: #c7d2fe;
  background: var(--primary-soft);
  font-weight: 600;
}

.ctrl-chip--green {
  color: #059669;
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.ctrl-btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: none;
  padding: 8px 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.ctrl-btn:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }

.ctrl-btn--primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: var(--shadow-btn); }
.ctrl-btn--primary:hover { background: var(--grad); color: #fff; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4); }

@media (max-width: 600px) {
  .control-bar { padding: 12px 14px; gap: 8px; }
  .ctrl-btn { font-size: 13px; padding: 7px 12px; }
}

/* ============ SUBMIT MODAL ============ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] { display: none; }

.modal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  padding: 36px 32px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-hover);
  text-align: center;
}

.modal-card h3 {
  margin: 8px 0 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--text);
}

.modal-sub {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-muted);
}

/* ============ AUTOCOMPLETE DROPDOWN ============ */

.suggest-menu {
  position: absolute;
  z-index: 90;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-hover);
}

.suggest-item {
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-faint);
}

.suggest-item:last-child { border-bottom: none; }

.suggest-item:hover,
.suggest-item.is-active { background: var(--primary-soft); color: var(--primary); }

/* ============ NOTICE BAR ============ */

.notice-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 32px;
  font-family: var(--font-body);
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.notice-bar[hidden] { display: none; }
.notice-bar--error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.notice-bar--ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }

.notice-action {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  padding: 6px 14px;
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.notice-action:hover { transform: translateY(-1px); box-shadow: var(--shadow-btn); }

/* ============ AUTH PAGE ============ */

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 30px 28px;
  background: var(--grad);
  color: #fff;
}

.auth-brand .diamond-logo {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.2), inset 0 0 0 2px rgba(124, 58, 237, 0.25);
}

.auth-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: none;
  color: #fff;
}

.auth-brand .masthead-sub { color: rgba(255, 255, 255, 0.8); }

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px;
}

.auth-form input[type="email"],
.auth-form input[type="password"] {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 11px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.auth-error {
  margin: 0;
  font-family: var(--font-body);
  font-size: 13px;
  color: #dc2626;
}

.btn-primary {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0;
  text-transform: none;
  padding: 12px 22px;
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: default; box-shadow: none; }

/* ============ REPORTS LIST PAGE ============ */

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  gap: 18px 22px;
  align-items: end;
  margin-bottom: 24px;
}

.filter-select {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--surface);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
}

.filter-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); background-color: var(--surface); }
.filter-apply { align-self: end; }

.reports-table td {
  padding: 12px;
  font-family: var(--font-body);
  font-size: 14px;
}

.cell-mono { font-family: var(--font-mono); font-size: 13px; }
.cell-small { font-size: 11.5px; color: var(--text-muted); }
.col-actions { width: 210px; }
/* Scrolls inside .table-scroll on phones instead of crushing the columns. */
.log-table--users { min-width: 720px; }
.cell-actions { white-space: nowrap; }

.status-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.status-tag--draft { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.status-tag--submitted { color: #047857; background: #ecfdf5; border-color: #a7f3d0; }
.status-tag--disabled { color: var(--text-muted); background: var(--bg); border-color: var(--border); }

.row-action {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--primary);
  background: transparent;
  border: none;
  padding: 2px 0;
  margin-right: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s ease;
}

.row-action:hover { color: var(--secondary); text-decoration: underline; }
.row-action--ghost { color: var(--text-muted); }
.row-action--ghost:hover { color: var(--text); }

.history-row td { background: var(--bg); }

.history-list {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 6px 2px;
}

.history-stamp {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 14px;
}

.empty-note {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-muted);
  padding: 18px 2px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
}

.pager-info { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }

@media (max-width: 860px) {
  .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reports-table { display: block; overflow-x: auto; }
}

/* ============ READ-ONLY MODE ============ */

.is-readonly .g-cell { pointer-events: none; cursor: default; }
.is-readonly .add-row, .is-readonly .del-row { display: none; }
.is-readonly input:disabled, .is-readonly select:disabled { opacity: 1; color: var(--text); }
.is-readonly .seg-btn, .is-readonly .pill { pointer-events: none; }

/* ============ ADMIN — USER MANAGEMENT & ANALYTICS ============ */

.admin-create-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px 24px;
  align-items: end;
  margin-bottom: 26px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.admin-create-form .btn-ghost { height: max-content; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metrics-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 14px;
}

.kpi-tile {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.kpi-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kpi-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 30px;
  margin-top: 8px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.kpi-unit { font-size: 14px; color: var(--text-muted); margin-left: 4px; -webkit-text-fill-color: var(--text-muted); }

/* Operating-metrics tiles hold longer values (e.g. "100.00%") — smaller value text so they fit. */
#operatingGrid .kpi-value { font-size: 22px; white-space: nowrap; }

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

.chart-panel {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  min-width: 0;
  box-shadow: var(--shadow-soft);
  transition: box-shadow 0.2s ease;
}

.chart-panel:hover { box-shadow: var(--shadow-hover); }

.chart-panel h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  text-transform: none;
  margin: 0 0 14px;
  color: var(--text);
}

.chart-canvas-wrap { position: relative; height: 260px; }

.analytics-note {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 18px;
}

@media (max-width: 760px) {
  .admin-create-form { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
}

/* ============ MOTION PREFERENCES ============ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ============ PRINT ============ */

@media print {
  body { padding: 0; background: #fff; }
  body::before, body::after { display: none; }
  .sheet { box-shadow: none; border-width: 1px; max-width: none; border-radius: 0; }
  .add-row, .del-row, .summary-actions, .bar-hint, .notice-bar,
  .ctrl-btn, .suggest-menu, .modal-overlay { display: none; }
  .control-bar { border-bottom-width: 1px; }
  .summary-bar { position: static; break-inside: avoid; }
  .gantt-scroll, .table-scroll { overflow: visible; max-height: none; }
  .log-section { break-inside: avoid; }
  .log-section:has(#gantt) { break-before: page; }
  .masthead { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .g-cell.is-on, .g-cat, .section-num, .diamond-logo, .summary-bar,
  .g-corner, .g-hour, .g-total-head, .legend-swatch, .status-tag, .meta-chip,
  .kpi-value, .masthead h1 {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .gantt { min-width: 0; }
  .log-table--dense { min-width: 0; }
  .col-del { display: none; }
}
