/* AUTO-SYNCED to native-webview/bin/ — edit source in app/ only */

:root {
  /* Canvas + surfaces */
  --bg: #F3F1ED;
  --panel: #ffffff;
  --panel-sunk: #FAF9F6;

  /* Ink + text */
  --ink: #182830;
  --ink-soft: #3C4C52;
  --muted: #7A8C90;

  /* Lines — used sparingly */
  --line: #D3CEC6;
  --line-soft: #E7E3DC;

  /* Brand accent */
  --accent: #176B5F;
  --accent-dark: #0F4F46;
  --accent-tint: #E6F0EE;

  /* Sidebar */
  --side-bg: #1B3039;
  --side-active: rgba(255,255,255,0.13);
  --side-text: #ffffff;
  --side-text-2: #C5DEDD;
  --side-text-3: #8CAEAA;

  /* Status */
  --danger: #B42318;
  --danger-tint: #FBEAE8;
  --warn: #B76E00;
  --warn-tint: #FBF1E2;
  --ok-tint: #E6F0EE;

  /* Elevation */
  --shadow-card: 0 1px 2px rgba(24,40,48,0.04), 0 4px 16px rgba(24,40,48,0.06);
  --shadow-pop: 0 12px 40px rgba(16,32,40,0.18);

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

/* ── Sidebar ─────────────────────────────────────────── */

.sidebar {
  width: 248px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  padding: 24px 16px;
  background: var(--side-bg);
  border-right: 1px solid rgba(0,0,0,0.15);
}

.logo-block {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-word {
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  color: var(--side-text);
  letter-spacing: -0.02em;
}

.logo-version {
  align-self: flex-end;
  margin-left: 1px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  color: var(--side-text-3);
  opacity: 0.85;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

/* Nav buttons use div[role=button] to avoid WebView2 host <button> style injection
   that overrides color and makes sidebar text appear black */
.nav-button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--side-text-2);
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  /* Reset any host-injected button styles */
  -webkit-appearance: none;
  appearance: none;
  text-decoration: none;
  line-height: 1.4;
  user-select: none;
}

.nav-button svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-button:hover {
  background: var(--side-active);
  color: var(--side-text);
}

.nav-button.active {
  background: var(--side-active);
  color: var(--side-text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
}

.nav-button:focus-visible {
  outline: 2px solid var(--side-text-2);
  outline-offset: 2px;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-button.nav-tertiary {
  color: var(--side-text-3);
  font-size: 13px;
}

.nav-button.nav-tertiary:hover {
  background: transparent;
  color: var(--side-text-2);
}

/* ── Typography ──────────────────────────────────────── */

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar .eyebrow,
.sidebar .subtle {
  color: var(--side-text-3);
}

.sidebar .warning-text {
  color: #ffd27a;
}

.subtle {
  color: var(--muted);
  font-size: 14px;
}

/* ── Main content area ───────────────────────────────── */

.main {
  overflow: hidden;
  position: relative;
  min-height: 0;
}

.view {
  position: absolute;
  inset: 0;
  padding: 32px;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  overflow: hidden;
}

.view.active {
  position: absolute;
  inset: 0;
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  overflow-y: auto;
  overflow-x: hidden;
}

.view-header,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

/* ── Summary cards ───────────────────────────────────── */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.summary-card {
  padding: 20px;
  background: var(--panel);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.summary-card.danger strong {
  color: var(--danger);
}

.summary-card.warn strong {
  color: var(--warn);
}

/* ── Panel ───────────────────────────────────────────── */

.panel {
  padding: 24px;
  background: var(--panel);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}

/* ── Project + task cards ────────────────────────────── */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.project-card,
.task-card {
  padding: 24px;
  background: var(--panel);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
}

.project-card:hover,
.task-card:hover {
  box-shadow: 0 2px 4px rgba(24,40,48,0.06), 0 8px 24px rgba(24,40,48,0.10);
  transform: translateY(-1px);
  transition: box-shadow 150ms ease, transform 150ms ease;
  cursor: pointer;
}

.draggable-card {
  cursor: grab;
}

.draggable-card:active {
  cursor: grabbing;
}

.dragging-card {
  opacity: 0.45;
}

.drop-before {
  box-shadow: inset 0 4px 0 var(--accent);
}

.drop-after {
  box-shadow: inset 0 -4px 0 var(--accent);
}

.project-card.drop-before {
  box-shadow: inset 4px 0 0 var(--accent);
}

.project-card.drop-after {
  box-shadow: inset -4px 0 0 var(--accent);
}

.drag-ghost {
  display: none !important;
}

.drag-placeholder {
  background: var(--accent-tint);
  border: 2px dashed var(--accent);
  border-radius: var(--r-md);
  box-sizing: border-box;
}

.project-card header,
.task-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.project-card header > div,
.task-card header > div {
  min-width: 0;
}

.card-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 14px;
  margin-top: 14px;
  overflow-x: auto;
}

/* ── Buttons ─────────────────────────────────────────── */

.nav-button,
.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.primary-button {
  padding: 10px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border: 0;
  border-radius: var(--r-sm);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.primary-button:active {
  transform: translateY(0.5px);
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary-button:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

.secondary-button {
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  border-radius: var(--r-sm);
}

.secondary-button:hover {
  background: var(--panel-sunk);
  border-color: #C2BCB2;
}

.secondary-button.danger-button {
  color: var(--danger);
  border-color: #E7B6B1;
}

.secondary-button.danger-button:hover {
  background: var(--danger-tint);
}

.secondary-button:focus-visible {
  outline: 2px solid var(--ink-soft);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.icon-button {
  width: 28px;
  height: 28px;
  background: var(--panel-sunk);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.text-button:hover {
  text-decoration: underline;
}

.text-button.danger {
  color: var(--danger);
}

.text-button:focus-visible {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── Inputs ──────────────────────────────────────────── */

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #C2BCB2;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--panel-sunk);
  color: var(--muted);
}

textarea {
  resize: vertical;
}

/* ── Dialogs ─────────────────────────────────────────── */

dialog {
  width: min(760px, calc(100vw - 30px));
  border: 0;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  padding: 28px;
}

dialog::backdrop {
  background: rgba(16,32,40,0.40);
}

/* ── Form layout ─────────────────────────────────────── */

.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form h3,
.form .wide,
.form-actions {
  grid-column: 1 / -1;
}

.form label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* ── Task list ───────────────────────────────────────── */

.task-list {
  display: grid;
  gap: 10px;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* ── Pills ───────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 22px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #EAE7E1;
  color: #4E5961;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.p1 {
  background: var(--danger-tint);
  color: #9B1C13;
}

.pill.p2 {
  background: var(--warn-tint);
  color: #875000;
}

.pill.p3 {
  background: var(--accent-tint);
  color: #0F4F46;
}

.pill.p4 {
  background: #EAE7E1;
  color: #4E5961;
}

/* ── Filters ─────────────────────────────────────────── */

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 160px;
  gap: 10px;
  margin-bottom: 14px;
}

/* ── Print ───────────────────────────────────────────── */

.print-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 16px;
}

.print-panel label:not(.check-row) {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.print-panel .subtle {
  grid-column: 1 / -1;
  margin: 0;
}

.settings-danger-zone {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.print-output {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  padding: 18px;
}

.print-header {
  margin-bottom: 18px;
}

.print-header p {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 20px;
  font-size: 13px;
}

.print-table th,
.print-table td {
  border: 1px solid var(--line);
  padding: 7px;
  text-align: left;
  vertical-align: top;
}

.print-table th {
  background: var(--accent-tint);
}

/* ── Settings ────────────────────────────────────────── */

.full-width {
  width: 100%;
}

.settings-panel {
  max-width: 720px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.check-row input {
  width: auto;
}

/* ── Empty state ─────────────────────────────────────── */

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  color: var(--muted);
  text-align: center;
}

/* ── Mini dashboard ──────────────────────────────────── */

.mini-dashboard {
  position: fixed;
  display: flex;
  flex-direction: column;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: 220px;
  min-height: 260px;
  max-height: 80vh;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  padding: 0;
  resize: vertical;
  transition: transform 0.18s ease;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.mini-dashboard.hidden {
  display: none;
}

.mini-dashboard.dragging {
  transition: none;
}

.mini-dashboard.edge-hidden-left:not(:hover) {
  transform: translateX(calc(-100% + 12px));
}

.mini-dashboard.edge-hidden-top:not(:hover) {
  transform: translateY(calc(-100% + 12px));
}

/* edge-hidden-right intentionally removed — right edge no longer auto-hides */

.mini-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--line);
  cursor: move;
  user-select: none;
}

#miniContent {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px 12px;
  overflow-x: hidden;
  overflow-y: auto;
}

#openFullApp {
  flex: 0 0 auto;
  margin: 0 12px 12px;
}

.mini-next {
  background: var(--accent-tint);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 9px 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.mini-task-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.mini-task-list {
  display: grid;
  gap: 6px;
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 13px;
}

.mini-task-list li {
  overflow-wrap: anywhere;
}

.mini-task-item {
  padding: 4px 3px;
  border-radius: 4px;
}

.mini-count-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .summary-grid,
  .filters,
  .print-panel,
  .form {
    grid-template-columns: 1fr;
  }

  .mini-dashboard {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

/* ── Print media ─────────────────────────────────────── */

@media print {
  body * {
    visibility: hidden;
  }

  #printArea,
  #printArea * {
    visibility: visible;
  }

  #printArea {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: 0;
    padding: 0;
  }
}

/* ── Reduced motion ──────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
