/* ===================================================================
   Groundwork Labs — Owner Dashboard
   Aesthetic: blueprint-dark control room. Coffee-tinted darks, parchment
   ink, teal/emerald/steel instruments. Defaults to dark; light theme via
   [data-theme="light"]. Single-column on mobile, sidebar on desktop.
   =================================================================== */

:root,
[data-theme="dark"] {
  --bg: #16110b;
  --bg-2: #1d1710;
  --panel: #221b13;
  --panel-2: #2a2118;
  --ink: #f4ece2;
  --ink-soft: #c9bdac;
  --ink-faint: #8d8273;
  --line: rgba(244, 236, 226, 0.10);
  --line-strong: rgba(244, 236, 226, 0.20);

  --teal: #2aa494;
  --emerald: #4fd092;
  --steel: #7EB5C4;
  --amber: #d8a24a;
  --rose: #d57a6c;

  --grid-line: rgba(126, 181, 196, 0.06);
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.8);
}

[data-theme="light"] {
  --bg: #FCF6F1;
  --bg-2: #f5ece2;
  --panel: #ffffff;
  --panel-2: #f7efe6;
  --ink: #1E1002;
  --ink-soft: #4a3c2c;
  --ink-faint: #8a7c69;
  --line: rgba(30, 16, 2, 0.12);
  --line-strong: rgba(30, 16, 2, 0.24);

  --teal: #006960;
  --emerald: #2f9f6a;
  --steel: #5b94a6;
  --amber: #b07d1f;
  --rose: #bb5547;

  --grid-line: rgba(0, 105, 96, 0.07);
  --shadow: 0 18px 40px -28px rgba(30, 16, 2, 0.4);
}

:root {
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 10px;
  --radius-sm: 7px;
}

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

/* Ensure the [hidden] attribute always wins: .login/.app set an explicit
   `display`, which would otherwise override the UA `[hidden] { display:none }`
   rule and leave the dashboard sidebar showing over the login screen. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 40%, transparent 100%);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: var(--steel); }

button { font-family: inherit; }

/* --------------------------- buttons --------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.btn:hover { border-color: var(--teal); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--primary { background: var(--teal); border-color: var(--teal); color: #06130f; font-weight: 600; }
.btn--primary:hover { background: var(--emerald); border-color: var(--emerald); }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--rose); border-color: transparent; background: transparent; padding: 0 10px; min-height: 36px; }
.btn--danger:hover { border-color: var(--rose); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn--github { background: #1f2328; color: #fff; border-color: #1f2328; font-weight: 600; }
.btn--github:hover { background: #32383f; border-color: #32383f; }

/* --------------------------- login --------------------------- */
.login {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login__card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 40px 34px;
  text-align: center;
  box-shadow: var(--shadow);
}
.login__mark { width: 52px; height: 52px; margin: 0 auto 18px; }
.login__eyebrow {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--ink-faint);
  margin: 0 0 6px;
}
.login__title { font-size: 30px; margin-bottom: 10px; }
.login__sub { color: var(--ink-soft); margin: 0 0 26px; font-size: 14px; }
.login__card .btn { width: 100%; }
.login__error { color: var(--rose); font-size: 13px; min-height: 18px; margin: 16px 0 0; }

/* --------------------------- app shell --------------------------- */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark { width: 28px; height: 28px; }
.brand__name { font-family: var(--font-display); font-weight: 600; font-size: 18px; }

.nav { display: flex; flex-wrap: wrap; gap: 6px; }
.nav__item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav__item:hover { color: var(--ink); background: var(--panel); }
.nav__item.is-active { color: var(--ink); background: var(--panel-2); border-color: var(--line-strong); }

.sidebar__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 4px; }
.theme-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); color: var(--ink-soft);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13px;
}
.theme-toggle__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 0 3px rgba(79,208,146,.18); }
.who { font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint); margin: 0; flex: 1; min-width: 120px; }
.logout { font-size: 13px; color: var(--ink-faint); text-decoration: none; }
.logout:hover { color: var(--rose); }

.content { padding: 26px clamp(18px, 4vw, 40px) 80px; }

@media (min-width: 860px) {
  .app { grid-template-columns: 232px 1fr; }
  .sidebar {
    border-bottom: none;
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
    height: 100vh;
  }
  .nav { flex-direction: column; flex-wrap: nowrap; }
  .sidebar__foot { margin-top: auto; flex-direction: column; align-items: flex-start; }
}

/* --------------------------- view header --------------------------- */
.view__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.view__title { font-size: 28px; }
.view__sub { color: var(--ink-faint); font-size: 13px; margin: 4px 0 0; }
.eyebrow {
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .16em;
  font-size: 11px; color: var(--teal); margin: 0 0 6px;
}

/* --------------------------- cards / panels --------------------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--teal);
}
.stat--emerald::after { background: var(--emerald); }
.stat--steel::after { background: var(--steel); }
.stat--amber::after { background: var(--amber); }
.stat__label {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-faint); margin: 0 0 8px;
}
.stat__value { font-family: var(--font-display); font-size: 30px; font-weight: 600; line-height: 1; }
.stat__hint { font-size: 12px; color: var(--ink-soft); margin: 8px 0 0; }

.overview-cols {
  display: grid; gap: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .overview-cols { grid-template-columns: 1fr 1fr; } }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel__title { font-size: 16px; font-family: var(--font-display); }
.panel__link { font-size: 12px; cursor: pointer; background: none; border: none; color: var(--steel); }

/* --------------------------- tables --------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
thead th {
  text-align: left; font-family: var(--font-mono); font-weight: 500; font-size: 11px;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint);
  padding: 12px 14px; background: var(--panel-2); border-bottom: 1px solid var(--line);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { background: var(--panel); transition: background .12s; }
tbody tr:hover { background: var(--panel-2); }
.cell-actions { white-space: nowrap; text-align: right; }
.num { font-family: var(--font-mono); }

/* --------------------------- concept cards --------------------------- */
.concept-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.concept {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.concept__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.concept__title { font-size: 18px; }
.concept__price { font-family: var(--font-mono); color: var(--emerald); font-size: 14px; white-space: nowrap; }
.concept__desc { color: var(--ink-soft); font-size: 13.5px; margin: 0; flex: 1; }
.concept__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.concept__link { font-size: 12px; font-family: var(--font-mono); color: var(--steel); word-break: break-all; }

/* --------------------------- todos --------------------------- */
.todo-add { display: flex; gap: 8px; margin-bottom: 16px; }
.todo-add input { flex: 1; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.todo {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.todo__check {
  appearance: none; width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--line-strong);
  cursor: pointer; flex-shrink: 0; position: relative; background: transparent;
}
.todo__check:checked { background: var(--emerald); border-color: var(--emerald); }
.todo__check:checked::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid #06130f; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.todo__text { flex: 1; }
.todo.is-done .todo__text { text-decoration: line-through; color: var(--ink-faint); }

/* --------------------------- integrations --------------------------- */
.integration-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.integration {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.integration__top { display: flex; align-items: center; gap: 10px; }
.integration__name { font-weight: 600; font-size: 15px; flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot--on { background: var(--emerald); box-shadow: 0 0 0 3px rgba(79,208,146,.18); }
.dot--off { background: var(--ink-faint); }
.badge {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 7px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--ink-soft);
}
.badge--green { color: var(--emerald); border-color: rgba(79,208,146,.4); }
.integration__note { font-size: 12px; color: var(--ink-faint); margin: 0; min-height: 16px; }
.integration__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.switch input { accent-color: var(--teal); width: 16px; height: 16px; }

.actions-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* --------------------------- forms / modal --------------------------- */
label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=url], select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line-strong);
  color: var(--ink); border-radius: var(--radius-sm); padding: 10px 12px;
  font-family: inherit; font-size: 14px; min-height: 42px;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; border-color: var(--teal); }
.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
.modal__panel {
  position: relative; width: min(100%, 520px); max-height: 90vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px;
  padding: 24px; box-shadow: var(--shadow);
}
.modal__title { font-size: 21px; margin-bottom: 18px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* --------------------------- misc --------------------------- */
.empty {
  text-align: center; padding: 44px 20px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius); color: var(--ink-faint);
}
.empty__title { font-family: var(--font-display); font-size: 18px; color: var(--ink-soft); margin: 0 0 6px; }
.skeleton { background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 37%, var(--panel) 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-row { height: 56px; margin-bottom: 10px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 60; background: var(--panel-2); border: 1px solid var(--line-strong);
  color: var(--ink); padding: 12px 18px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow); max-width: 90vw;
}
.toast--error { border-color: var(--rose); color: var(--rose); }
.toast--ok { border-color: var(--emerald); }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: color-mix(in srgb, var(--amber) 12%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent);
  color: var(--ink); padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px;
  margin-bottom: 20px;
}
.notice code { font-family: var(--font-mono); font-size: 12px; }

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
