:root {
  --ink:      #0d1a0f;
  --ink-2:    #152017;
  --ink-3:    #1c2b1e;
  --paper:    #f0ead8;
  --paper-2:  #e6dfca;
  --gold:     #b8913f;
  --gold-dim: rgba(184,145,63,.45);
  --locked-bg:     #fff2cc;
  --locked-border: #ffd966;
  --error:    #c0392b;
  --success:  #1a6b3a;

  --radius: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,.12);
  --transition: .15s ease;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Typography ── */
h1, h2, h3 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover:not(:disabled) { background: var(--ink-2); }
.btn-gold {
  background: var(--gold);
  color: #fff;
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.08); }
.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink-3);
}
.btn-outline:hover:not(:disabled) { background: var(--paper-2); }
.btn-danger {
  background: var(--error);
  color: #fff;
}

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
}

.login-card {
  background: var(--paper);
  border-radius: 8px;
  padding: 48px 40px;
  width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.login-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 36px;
  font-weight: 300;
  color: var(--ink);
  letter-spacing: .05em;
  margin-bottom: 8px;
}
.login-logo span {
  color: var(--gold);
  font-weight: 500;
}
.login-subtitle {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 36px;
}

.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  background: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--ink);
  transition: border-color var(--transition);
}
.form-group input:focus {
  outline: none;
  border-color: var(--gold);
}

.login-error {
  background: #fde8e8;
  color: var(--error);
  border: 1px solid #f5c6c6;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.visible { display: block; }

.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 14px;
  margin-top: 8px;
}

/* ── App layout ── */
.app-header {
  background: var(--ink);
  color: var(--paper);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 300;
  letter-spacing: .05em;
  white-space: nowrap;
}
.header-logo span { color: var(--gold); font-weight: 500; }
.header-logo small {
  font-size: 11px;
  font-family: 'DM Sans', sans-serif;
  color: rgba(240,234,216,.5);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-left: 6px;
}

.header-selectors {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

select.selector {
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius);
  background: rgba(255,255,255,.08);
  color: var(--paper);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  cursor: pointer;
  min-width: 200px;
}
select.selector option { background: var(--ink-2); color: var(--paper); }
select.selector:disabled { opacity: .4; cursor: not-allowed; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}
.user-info {
  font-size: 12px;
  color: rgba(240,234,216,.6);
}

/* ── Toolbar ── */
.toolbar {
  background: var(--paper-2);
  border-bottom: 1px solid #d4ccb0;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toolbar .status {
  margin-left: auto;
  font-size: 12px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
}
.status-dot.ok { background: var(--success); }
.status-dot.error { background: var(--error); }
.status-dot.loading {
  background: var(--gold);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Task table ── */
.table-container {
  overflow-x: auto;
  padding: 0 24px 40px;
}

.task-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 13px;
}

.task-table th {
  background: var(--ink-3);
  color: var(--paper);
  padding: 9px 10px;
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  position: sticky;
  top: 56px;
  z-index: 10;
}

.task-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #ddd4ba;
  vertical-align: middle;
}

/* Parent rows (level 1-3) */
.task-table tr.level-1 td,
.task-table tr.level-2 td,
.task-table tr.level-3 td {
  background: var(--paper-2);
  font-weight: 600;
}

/* Locked rows */
.task-table tr.locked td {
  background: var(--locked-bg);
}
.task-table tr.locked td.cell-dur,
.task-table tr.locked td.cell-pred {
  background: #fff2cc;
  border: 1px solid var(--locked-border);
}

/* Description indentation */
td.task-desc { max-width: 360px; }
.desc-indent { display: inline-block; }

/* Editable inputs */
td input.cell-input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--ink);
  transition: border-color var(--transition), background var(--transition);
}
td input.cell-input:not(:disabled):focus {
  border-color: var(--gold);
  background: #fff;
  outline: none;
}
td input.cell-input:disabled {
  cursor: default;
  opacity: .7;
}

.lock-icon { margin-right: 4px; font-size: 11px; }
.pct-badge {
  display: inline-block;
  background: var(--ink-2);
  color: var(--paper);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
}
.pct-badge.partial { background: var(--gold); color: #fff; }
.pct-badge.full { background: var(--success); color: #fff; }

/* ── Empty / Loading states ── */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  color: #888;
  gap: 12px;
}
.state-container h3 {
  font-size: 20px;
  color: var(--ink);
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--paper-2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 72px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 6px;
  min-width: 280px;
  max-width: 420px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--error); color: #fff; }
.toast-info { background: var(--ink); color: var(--paper); }
@keyframes slideIn { from { transform: translateX(120%); opacity:0 } to { transform: translateX(0); opacity:1 } }

/* ── Confirm dialog ── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dialog-overlay.hidden { display: none; }
.dialog-box {
  background: var(--paper);
  border-radius: 8px;
  padding: 32px 28px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,.3);
}
.dialog-box h3 { font-size: 22px; margin-bottom: 12px; }
.dialog-box p { font-size: 13px; color: #555; margin-bottom: 24px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ── Error page ── */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px;
  text-align: center;
}
.error-page h2 { font-size: 32px; color: var(--error); margin-bottom: 16px; }
.error-page p { color: #666; max-width: 480px; }
