/* ==========================================================================
   Timebook · design tokens & base
   ========================================================================== */

:root {
  --bg: #0f1115;
  --bg-elev: #161922;
  --bg-card: #1a1e29;
  --bg-input: #232836;
  --border: #2a3142;
  --border-soft: #232836;
  --text: #e6e8ee;
  --text-mute: #9aa0b0;
  --text-dim: #6b7180;
  --accent: #f59e0b;        /* warm amber */
  --accent-soft: #f59e0b22;
  --accent-strong: #fbbf24;
  --success: #10b981;
  --success-soft: #10b98122;
  --warn: #f59e0b;
  --warn-soft: #f59e0b1a;
  --error: #ef4444;
  --error-soft: #ef44441f;
  --info: #6366f1;
  --info-soft: #6366f11a;
  --shadow: 0 1px 0 0 #00000040, 0 10px 30px -10px #00000060;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-mute); }

/* ==========================================================================
   Top bar & layout
   ========================================================================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  font-size: 18px;
  color: var(--accent);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.navlink {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mute);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: color .15s, background .15s;
}
.navlink:hover { color: var(--text); background: var(--bg-elev); text-decoration: none; }
.navlink.is-active { color: var(--accent-strong); }

.logout-form { display: inline; margin: 0; padding: 0; }
.logout-btn { font-family: var(--font-body); }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 28px 96px;
}

/* ==========================================================================
   Page header
   ========================================================================== */

.page-head {
  margin-bottom: 28px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 500;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.page-sub {
  color: var(--text-mute);
  font-size: 14px;
  margin: 0;
  max-width: 720px;
}

.week-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #1d2230 0%, var(--bg-card) 100%);
}

.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

.card-body {
  padding: 20px;
}
.card-body > p:first-child { margin-top: 0; }
.card-body > p:last-child { margin-bottom: 0; }

/* ==========================================================================
   Forms, buttons, inputs
   ========================================================================== */

.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .05s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #1a1300;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-elev); border-color: var(--text-dim); }

.btn-block { width: 100%; }
.btn-lg { padding: 12px 22px; font-size: 14px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-icon {
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-mute);
  cursor: pointer;
  font-size: 16px;
}
.btn-icon:hover { color: var(--error); border-color: var(--error); }

.form-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}
.form-row .field { margin-bottom: 0; }
.flex-grow { flex: 1; }

.divider {
  text-align: center;
  position: relative;
  margin: 22px 0 16px;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.divider::before, .divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 30px);
  height: 1px;
  background: var(--border-soft);
}
.divider::before { left: 0; }
.divider::after { right: 0; }
.divider span { background: var(--bg-card); padding: 0 12px; }

/* ==========================================================================
   Alerts & statuses
   ========================================================================== */

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 13px;
  margin-bottom: 18px;
}
.alert-error { background: var(--error-soft); border-color: var(--error); color: #fda4a4; }
.alert-success { background: var(--success-soft); border-color: var(--success); color: #6ee7b7; }
.alert-info { background: var(--info-soft); border-color: var(--info); color: #a5b4fc; }

.status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 500;
}
.status-on { background: var(--success-soft); color: #6ee7b7; }
.status-off { background: var(--bg-input); color: var(--text-mute); }

/* ==========================================================================
   Rules table
   ========================================================================== */

.rules-table, .manual-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}
.rules-table th, .manual-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--border-soft);
}
.rules-table td, .manual-table td {
  padding: 8px 10px 8px 0;
  vertical-align: middle;
}
.rules-table td:last-child, .manual-table td:last-child { padding-right: 0; }

.rules-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

/* ==========================================================================
   Login
   ========================================================================== */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1a1e29 0%, #0f1115 60%);
}

.login-shell {
  text-align: center;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 36px 36px 32px;
  width: 380px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 22px;
  letter-spacing: -0.01em;
}

.login-form .field { margin-bottom: 16px; text-align: left; }
.login-form .btn { margin-top: 8px; }

.login-note {
  margin-top: 18px;
  color: var(--text-dim);
  font-size: 12px;
}

/* ==========================================================================
   Week summary
   ========================================================================== */

.week-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.metric {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.metric-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-mute);
  margin-bottom: 6px;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.metric-ok .metric-value { color: var(--success); }
.metric-warn .metric-value { color: var(--warn); }

/* ==========================================================================
   Day grid
   ========================================================================== */

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.day-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-weekend {
  background: #14171f;
  opacity: 0.7;
}

.day-needs {
  border-color: #614626;
}

.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 10px;
}

.day-meta { display: flex; gap: 6px; align-items: baseline; }
.day-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
}
.day-date { font-size: 11px; color: var(--text-mute); }

.day-totals { display: flex; gap: 6px; align-items: baseline; }
.day-total { font-size: 13px; font-weight: 500; }
.day-total.full { color: var(--success); }
.day-total.mostly { color: var(--accent-strong); }
.day-total.partial { color: var(--warn); }
.day-total.light { color: var(--text-mute); }
.day-total.empty { color: var(--text-dim); }
.day-booked { color: var(--success); font-size: 11px; }

.day-empty {
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
  margin: 0;
}

.bucket-row {
  background: var(--bg-elev);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
}

.bucket-locked {
  opacity: 0.7;
}

.bucket-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bucket-include {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.bucket-include input { width: auto; margin: 0; }

.bucket-name {
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bucket-unassigned { color: var(--warn); font-style: italic; }

.bucket-count {
  font-size: 10px;
  color: var(--text-dim);
  margin-right: 4px;
}

.hours-input {
  width: 60px;
  padding: 4px 6px;
  font-size: 12px;
  text-align: right;
  background: var(--bg-input);
}
.hours-input-readonly {
  font-size: 12px;
  color: var(--text);
  min-width: 38px;
  text-align: right;
}

.event-notes {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  font-size: 11px;
  color: var(--text-dim);
}
.event-notes li {
  padding-left: 10px;
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.event-notes li::before {
  content: "·";
  position: absolute;
  left: 2px;
  color: var(--text-mute);
}

.day-gap {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
  font-size: 11px;
  color: var(--text-mute);
  display: flex;
  justify-content: space-between;
}
.gap-value { color: var(--warn); font-weight: 600; }

/* ==========================================================================
   Manual section & submit bar
   ========================================================================== */

.manual-section { margin-top: 8px; }
.manual-table input, .manual-table select {
  padding: 7px 9px;
  font-size: 13px;
}

.submit-bar {
  position: sticky;
  bottom: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  box-shadow: var(--shadow);
}

.submit-hint {
  color: var(--text-mute);
  font-size: 13px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1100px) {
  .day-grid { grid-template-columns: repeat(4, 1fr); }
  .day-card:nth-child(n+5) { grid-column: span 1; }
}

@media (max-width: 800px) {
  .day-grid { grid-template-columns: repeat(2, 1fr); }
  .week-summary { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; align-items: stretch; }
  .container { padding: 24px 16px 96px; }
  .page-title { font-size: 26px; }
}

@media (max-width: 500px) {
  .day-grid { grid-template-columns: 1fr; }
  .topnav { gap: 2px; }
  .navlink { padding: 6px 8px; font-size: 12px; }
}
