/* =========================================================================
   Geis Construction Dashboard — stylesheet
   Restrained, professional, editorial. Built around the logo's blue.
   No gradients, no animation kitsch — this is a daily-use compliance tool.
   ========================================================================= */

:root {
  /* Brand colors pulled from the Geis logo */
  --brand-primary: #1976D2;
  --brand-primary-light: #4FC3F7;
  --brand-primary-dark: #0D47A1;
  --brand-primary-tint: #E3F2FD;

  /* Neutral palette */
  --ink: #1a202c;
  --ink-soft: #4a5568;
  --ink-faint: #718096;
  --line: #e2e8f0;
  --line-soft: #edf2f7;
  --paper: #ffffff;
  --paper-soft: #f7fafc;
  --paper-tint: #fbfcfd;

  /* Status colors */
  --ok: #2f855a;
  --ok-tint: #f0fff4;
  --warn: #c05621;
  --warn-tint: #fffaf0;
  --bad: #c53030;
  --bad-tint: #fff5f5;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 4px 6px rgba(15, 23, 42, 0.04), 0 12px 24px rgba(15, 23, 42, 0.08);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  --font-display: "Source Serif Pro", "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Consolas", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper-soft);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "header header"
    "sidebar main";
}

.app-header {
  grid-area: header;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 10;
}
.app-header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
}
.app-header .logo img {
  height: 36px;
  width: auto;
}
.app-header .logo .title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1;
  border-left: 1px solid var(--line);
  padding-left: 12px;
}
.app-header .logo .title small {
  display: block;
  margin-top: 4px;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.app-header .header-spacer { flex: 1; }
.app-header .header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: var(--ink-soft);
}
.app-header .header-actions form { display: inline; }

.app-sidebar {
  grid-area: sidebar;
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 24px 12px;
}
.app-sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.app-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--ink-soft);
  font-size: 14px;
  border-radius: var(--radius-md);
  transition: background 0.1s, color 0.1s;
}
.app-sidebar nav a:hover {
  background: var(--paper-soft);
  color: var(--ink);
  text-decoration: none;
}
.app-sidebar nav a.active {
  background: var(--brand-primary-tint);
  color: var(--brand-primary-dark);
  font-weight: 500;
}
.app-sidebar nav .section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 16px 12px 6px;
}

.app-main {
  grid-area: main;
  padding: 32px 40px;
  overflow: auto;
}

/* ---------- Typography ---------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  letter-spacing: -0.015em;
  margin: 0 0 0.4em;
  line-height: 1.2;
}
h1 { font-size: 28px; font-weight: 600; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.page-header .page-title h1 { margin: 0; }
.page-header .page-title .lede {
  margin-top: 6px;
  color: var(--ink-faint);
  font-size: 14px;
}
.page-header .page-actions { display: flex; gap: 8px; }

.muted { color: var(--ink-faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }

/* ---------- Cards ---------- */

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card .card-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.card .card-title .meta {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* ---------- Tables ---------- */

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-tint);
}
table.data tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--paper-soft); }
table.data tbody tr:last-child td { border-bottom: none; }

table.data .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
  text-decoration: none;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.btn:hover {
  background: var(--paper-soft);
  text-decoration: none;
}
.btn.primary {
  background: var(--brand-primary);
  color: var(--paper);
  border-color: var(--brand-primary);
}
.btn.primary:hover {
  background: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
  color: var(--paper);
}
.btn.danger {
  color: var(--bad);
  border-color: var(--line);
}
.btn.danger:hover {
  background: var(--bad-tint);
  border-color: var(--bad);
}
.btn.small {
  padding: 4px 10px;
  font-size: 13px;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Forms ---------- */

.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 5px;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.12);
}
.field textarea { min-height: 80px; resize: vertical; }
.field .help {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-faint);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  background: var(--paper-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.badge.ok { background: var(--ok-tint); color: var(--ok); border-color: rgba(47, 133, 90, 0.2); }
.badge.warn { background: var(--warn-tint); color: var(--warn); border-color: rgba(192, 86, 33, 0.2); }
.badge.bad { background: var(--bad-tint); color: var(--bad); border-color: rgba(197, 48, 48, 0.2); }
.badge.brand { background: var(--brand-primary-tint); color: var(--brand-primary-dark); border-color: rgba(25, 118, 210, 0.2); }

/* ---------- Notices ---------- */

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid;
}
.notice.info { background: var(--brand-primary-tint); color: var(--brand-primary-dark); border-color: rgba(25, 118, 210, 0.18); }
.notice.ok { background: var(--ok-tint); color: var(--ok); border-color: rgba(47, 133, 90, 0.2); }
.notice.warn { background: var(--warn-tint); color: var(--warn); border-color: rgba(192, 86, 33, 0.2); }
.notice.bad { background: var(--bad-tint); color: var(--bad); border-color: rgba(197, 48, 48, 0.2); }

/* ---------- Login screen ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-soft);
  background-image:
    radial-gradient(circle at 20% 30%, rgba(79, 195, 247, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(25, 118, 210, 0.04) 0%, transparent 50%);
}
.login-card {
  width: 380px;
  background: var(--paper);
  padding: 36px 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.login-card .brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-card .brand img {
  width: 120px;
  height: auto;
  display: block;
  margin: 0 auto 12px;
}
.login-card .brand .label {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.login-card h1 {
  text-align: center;
  font-size: 18px;
  margin-bottom: 6px;
}
.login-card .lede {
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
  margin-bottom: 22px;
}
.login-card .btn { width: 100%; justify-content: center; }

/* ---------- Templates grid (state x type) ---------- */

.template-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--paper);
}
.template-grid th, .template-grid td {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  vertical-align: middle;
}
.template-grid thead th {
  background: var(--paper-tint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.template-grid .state-cell {
  font-weight: 500;
  white-space: nowrap;
}
.template-grid td.cell-ready { background: var(--ok-tint); }
.template-grid td.cell-fallback { background: var(--warn-tint); }
.template-grid td.cell-missing { background: var(--bad-tint); }

/* ---------- Misc ---------- */

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-faint);
}
.empty-state .empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--ink);
  margin-bottom: 6px;
}

dl.meta {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 16px;
  font-size: 14px;
  margin: 0;
}
dl.meta dt {
  color: var(--ink-faint);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}
dl.meta dd { margin: 0; color: var(--ink); }
