/* Script.Breakdown — hosted shell (login, invite, projects, admin).
   Shares the desktop editor's design language: warm off-white ground,
   white cards, 1px hairlines, 4px radii, system UI type. */

:root {
  --bg: #fafaf7;
  --fg: #1a1a1a;
  --muted: #666;
  --line: #e0e0d8;
  --accent: #2c5282;
  --danger: #c53030;
  --warn: #d97706;
  --ok: #2f855a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
}

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.muted { color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- buttons */

button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  -webkit-user-select: none;
  user-select: none;
}
button:hover:not(:disabled) { background: #f0f0e8; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: #2a4d7a; }
button.danger { color: var(--danger); }
button.danger:hover:not(:disabled) {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
button.small { padding: 3px 9px; font-size: 12px; }
button.big { padding: 8px 16px; font-size: 14px; }
button.link {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font-size: 12px;
  text-decoration: underline;
}
button.link:hover:not(:disabled) { background: none; }

/* ----------------------------------------------------------------- fields */

label.field { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
label.field > span.label-text { display: block; margin-bottom: 4px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
}
input[type="email"],
input[type="password"] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[aria-invalid="true"] { border-color: var(--danger); }

.hint { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.field-error { display: block; margin-top: 4px; font-size: 11px; color: var(--danger); }

/* --------------------------------------------------------------- messages */

.alert {
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-error { background: #fdeaea; border: 1px solid #f0b6b6; color: #8a1f1f; }
.alert-warn { background: #fffbe6; border: 1px solid #d4b800; color: #6b5400; }
.alert-info { background: #eef3f9; border: 1px solid #c3d3e6; color: #234062; }
.alert-ok { background: #eaf7ef; border: 1px solid #a8d8bd; color: #1d5c39; }
.alert p { margin: 0 0 6px; }
.alert p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------- centered (auth) */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.auth-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 28px;
  width: 380px;
  max-width: 100%;
}
.auth-card h1 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.auth-card .sub { margin: 0 0 20px; font-size: 12px; color: var(--muted); }
.auth-actions { margin-top: 18px; }
.auth-actions button { width: 100%; padding: 8px 16px; font-size: 14px; }
.auth-foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ----------------------------------------------------------------- header */

.page-header {
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
.wordmark {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.header-spacer { flex: 1; }
.header-meta { font-size: 12px; color: var(--muted); }
.header-inner nav { display: flex; align-items: center; gap: 12px; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
}

/* ------------------------------------------------------------------ cards */

.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 20px;
}
.card > h2 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.card > h2 + .card-sub { margin: 0 0 14px; font-size: 12px; color: var(--muted); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

/* ------------------------------------------------------------------ usage */

.usage-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}
.usage-line strong { color: var(--fg); font-variant-numeric: tabular-nums; }
.meter {
  width: 140px;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.meter > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.meter.over > span { background: var(--danger); }

.figure-row { display: flex; gap: 40px; flex-wrap: wrap; }
.figure .figure-value {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.figure .figure-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ------------------------------------------------------------------ table */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
td.right, th.right { text-align: right; }
td.actions-cell { white-space: nowrap; text-align: right; }
td.actions-cell button + button { margin-left: 4px; }

.table-scroll { max-height: 420px; overflow-y: auto; }
.table-scroll thead th { position: sticky; top: 0; background: white; z-index: 1; }

/* --------------------------------------------------------------- projects */

.project-row { cursor: pointer; }
.project-row:hover { background: #f5f5ee; }
.project-title { font-weight: 500; }
.project-file {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  word-break: break-all;
}

.badge {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 1px 6px;
  border-radius: 3px;
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid var(--line);
}
.badge.ok { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge.off { background: #f3f4f6; color: #6b7280; }
.badge.pending { background: #fff8db; color: #6b5400; border-color: #e6d98a; }
.badge.role-admin { background: #dbeafe; color: #1e40af; border-color: #c3d3e6; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty p { margin: 0 0 6px; }

/* --------------------------------------------------------------- drop zone */

.drop-zone {
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: #fcfcf8;
  padding: 24px;
  text-align: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.drop-zone.over {
  background: #e8eef6;
  border-color: var(--accent);
}
.drop-zone.busy { opacity: 0.7; pointer-events: none; }
.drop-zone p { margin: 0 0 8px; font-size: 13px; }
.drop-zone .formats {
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}
.upload-status { margin-top: 12px; font-size: 13px; }
.upload-status .working { color: var(--accent); }

/* -------------------------------------------------------------- copy box */

.copy-box {
  background: #f8f8f0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  margin-top: 10px;
}
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: white;
}

/* -------------------------------------------------------------- admin bits */

.form-grid {
  display: grid;
  grid-template-columns: 1.4fr 1.2fr 0.7fr 0.8fr auto;
  gap: 10px;
  align-items: end;
}
.form-grid label.field { margin-bottom: 0; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  background: #f8f8f0;
  font-size: 12px;
  color: var(--muted);
}
.chip strong {
  display: block;
  font-size: 16px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.cap-cell { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cap-cell input[type="number"] { width: 72px; padding: 3px 6px; font-size: 12px; }

.rules-pre {
  max-height: 340px;
  overflow-y: auto;
  background: #f8f8f0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  margin: 0 0 12px;
}

.tagpair { font-size: 12px; }
.tagpair .arrow { color: var(--muted); margin: 0 4px; }
.tagpair .cat {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
  margin-right: 4px;
}

.loading { padding: 24px; color: var(--muted); font-size: 13px; text-align: center; }
