/* app.css — "Graphite & Blue" palette recreated from gui_kit.py */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1a1d22;
  --muted: #767e8a;
  --muted-strong: #565f6b;
  --accent: #2f5fd6;
  --accent-soft: #e8eefb;
  --sidebar: #1b212c;
  --sidebar-text: #c7cdd8;
  --sidebar-active: #242c3a;
  --badge-off-bg: #f0f1f3;
  --badge-off-fg: #b7bcc4;
  --slate: #dce1e7;
  --warning: #b45326;
  --warning-soft: #fbeee4;
  --seg-off-bg: #eef0f3;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
.muted { color: var(--muted); }

/* ---------------- login ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: 100%; max-width: 380px;
  box-shadow: 0 8px 30px rgba(27, 33, 44, 0.08);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-logo, .sidebar-logo {
  width: 44px; height: 44px; border-radius: 10px; background: var(--accent);
  color: #fff; font-weight: 700; display: grid; place-items: center; letter-spacing: .5px;
}
.login-brand h1 { font-size: 16px; margin: 0; }
.login-brand p { margin: 2px 0 0; font-size: 12px; }
.login-foot { text-align: center; margin: 16px 0 0; font-size: 11px; }

/* ---------------- layout ---------------- */
.layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 20px 14px;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 20px; }
.sidebar-title { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-title span { font-weight: 500; color: var(--sidebar-text); font-size: 12px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  color: var(--sidebar-text); text-decoration: none; padding: 9px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
}
.nav-item:hover { background: var(--sidebar-active); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.sidebar-foot { padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.developed-by { font-size: 11px; color: #6b7280; text-align: center; margin: 10px 0 0; }
.version { font-size: 11px; color: #6b7280; text-align: center; margin: 2px 0 0; }
.project-actions { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.save-flash { font-size: 11px; color: #7fd99a; text-align: center; margin: 0 0 8px; }

.project-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border);
  border-radius: 8px; overflow: hidden; max-height: 320px; overflow-y: auto; }
.project-item { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.project-item:last-child { border-bottom: none; }
.project-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-row-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.main-header { padding: 24px 32px 8px; }
.main-header h1 { font-size: 20px; margin: 0; }
.main-header p { margin: 4px 0 0; font-size: 13px; }
.body { padding: 16px 32px 32px; flex: 1; max-width: 900px; width: 100%; }

/* ---------------- cards ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 20px;
}
.card-title { font-size: 15px; margin: 0 0 16px; display: flex; align-items: baseline; gap: 8px; }
.card-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-intro { font-size: 12.5px; margin: -8px 0 16px; }

/* ---------------- fields ---------------- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.input {
  width: 100%; padding: 9px 11px; border: 2px solid var(--border); border-radius: 8px;
  font: inherit; color: var(--text); background: #fff; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-narrow { max-width: 320px; }
textarea.input { resize: vertical; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }

/* ---------------- personnel ---------------- */
.person-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.person-row.person-row-last { border-bottom: none; }
.person-row > select { flex: 1; max-width: 300px; }
.badges { display: flex; align-items: center; gap: 6px; }
.badge {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.badge.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.badge.disabled, .badge:disabled {
  background: var(--badge-off-bg); color: var(--badge-off-fg); border-color: var(--badge-off-bg);
  cursor: not-allowed;
}
.badge-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

/* ---------------- buttons ---------------- */
.btn {
  border: 1px solid transparent; border-radius: 8px; padding: 10px 18px; font: inherit;
  font-weight: 600; cursor: pointer; background: var(--slate); color: var(--text);
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn:focus-visible, .nav-item:focus-visible, .badge:focus-visible,
.seg-btn:focus-visible, .input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: #2a55c0; }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted-strong); }
.btn-ghost:hover { color: var(--text); }
.btn-delete { background: var(--warning-soft); color: var(--warning); }
.btn-delete:hover:not(:disabled) { background: color-mix(in srgb, var(--warning-soft) 85%, black); }
.sidebar .btn-ghost { border-color: rgba(255,255,255,.15); color: var(--sidebar-text); }
.sidebar .btn-ghost:hover { color: #fff; background: var(--sidebar-active); }

/* ---------------- uploads / dropzones ---------------- */
.hidden { display: none; }
.dropzone {
  border: 2px dashed color-mix(in srgb, var(--accent) 50%, var(--panel));
  border-radius: 8px; padding: 16px; text-align: center; color: var(--muted);
  font-weight: 600; cursor: pointer; margin-bottom: 12px; background: #fbfcfe;
}
.dropzone:hover { background: var(--accent-soft); color: var(--accent); }
.dropzone.busy { opacity: .7; cursor: progress; }
.chip-row { display: flex; align-items: center; gap: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
  background: var(--accent-soft); color: var(--accent); border-radius: 999px;
  font-size: 13px; font-weight: 600;
}
.chip-icon { font-size: 15px; }

.report-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.input-title { max-width: 190px; flex: 0 0 auto; }
.report-info { flex: 1; font-size: 13px; color: var(--text); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.report-counts { color: var(--muted); margin-left: 6px; }
.report-row-lab { flex-direction: column; align-items: stretch; gap: 8px; }
.report-row-top { display: flex; align-items: center; gap: 12px; }
.report-row-actions { display: flex; gap: 8px; }

/* ---------------- PCB / UW subsections ---------------- */
.subsection { padding: 12px 0; border-bottom: 1px solid var(--border); }
.subsection:last-child { border-bottom: none; }
.subsection-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.subsection-row { margin-top: 10px; }
.uw-q { flex: 1; margin: 0; }
.yesno-field { margin-bottom: 14px; }
.yesno-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.yesno-detail { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; margin-top: 8px; }
.yesno-lead { margin: 0 0 8px; font-size: 12.5px; color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg-btn { border: none; background: var(--seg-off-bg, #eef0f3); padding: 5px 14px; font: inherit;
  font-size: 11px; font-weight: bold; cursor: pointer; color: var(--muted-strong); }
.seg-btn.on { background: var(--accent); color: #fff; }

/* ---------------- modals ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 25, 33, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: var(--panel); border-radius: 12px; width: 100%; max-width: 460px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 6px; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-x { border: none; background: none; font-size: 16px; color: var(--muted-strong); cursor: pointer; }
.modal > p.muted { padding: 0 20px; margin: 4px 0 0; font-size: 12.5px; }
.modal-body { padding: 12px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--border); }

.sqft-row { display: flex; align-items: center; gap: 14px; padding: 8px 0;
  border-bottom: 1px solid var(--border); }
.sqft-mat { flex: 1; }
.sqft-material { display: block; font-weight: 600; font-size: 13px; }
.sqft-loc { display: block; font-size: 12px; color: var(--muted); }
.sqft-input { display: flex; align-items: center; gap: 6px; }
.sqft-input .input { width: 110px; }
.sqft-unit { color: var(--muted); font-size: 13px; }

.grid-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.grid-table th { text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); padding: 4px 6px; font-weight: 700; }
.grid-table td { padding: 3px 6px; }
.grid-table .input { padding: 6px 8px; }
.uw-cat { margin-bottom: 16px; }
.uw-cat-name { font-weight: 700; color: var(--accent); font-size: 13px; margin-bottom: 6px; }

/* ---------------- shared data (Phase 3) ---------------- */
.row-actions { display: flex; gap: 8px; align-items: center; }
.nowrap { white-space: nowrap; }
.modal-foot-inner { display: flex; gap: 10px; }
.person-form .field { margin-bottom: 12px; }

.acronym-add { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.acronym-add .input:not(.input-narrow) { flex: 1; }
.acronym-list { border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  max-height: 260px; overflow-y: auto; margin-bottom: 12px; }
.acronym-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); font-size: 13px; cursor: pointer; }
.acronym-item:last-child { border-bottom: none; }
.acronym-key { font-weight: 700; min-width: 60px; }
.acronym-arrow { color: var(--muted); }
.acronym-phrase { color: var(--text); }
.acronym-list .muted { padding: 12px; }

/* photolog */
.photolog-page-heading { font-size: 11px; font-weight: 700; color: var(--text);
  margin: 14px 0 4px; }
.photolog-page-heading:first-child { margin-top: 0; }
.photolog-row { display: flex; align-items: center; gap: 12px; padding: 9px 0;
  border-bottom: 1px solid var(--border); }
.photolog-row.dropped { opacity: .5; }
.photolog-mat { flex: 1; min-width: 0; }
.photolog-material { display: block; font-weight: 600; font-size: 13px; }
.photolog-loc { display: block; font-size: 12px; color: var(--muted); }
.photolog-photo { flex: 0 0 auto; }
.photolog-drop {
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px dashed color-mix(in srgb, var(--accent) 50%, var(--panel));
  border-radius: 8px; padding: 7px 13px; font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer; background: #fbfcfe;
}
.photolog-drop:hover { background: var(--accent-soft); color: var(--accent); }
.chip-x { border: none; background: none; color: var(--accent); cursor: pointer; font-weight: 700; padding: 0 0 0 4px; }

.alert-ok { background: #e9f6ee; color: #1c7a44; border: 1px solid #bfe4cd; }

.progress-wrap { margin: 10px 0; }
.progress-bar { height: 6px; border-radius: 999px; background: var(--seg-off-bg); overflow: hidden; }
.progress-bar-fill { height: 100%; width: 40%; border-radius: 999px; background: var(--accent);
  animation: progress-indeterminate 1.1s ease-in-out infinite; }
@keyframes progress-indeterminate {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}

.link-status { margin: 8px 0; }
.row-warning td { color: var(--warning); }

/* ---------------- footer / alerts ---------------- */
.main-footer {
  position: sticky; bottom: 0; display: flex; align-items: center; gap: 12px;
  padding: 14px 32px; background: rgba(244,245,247,.92); border-top: 1px solid var(--border);
  backdrop-filter: blur(4px);
}
.spacer { flex: 1; }
.alert { border-radius: 8px; padding: 12px 14px; margin-bottom: 18px; font-size: 13px; }
.alert-error { background: var(--warning-soft); color: var(--warning); border: 1px solid #f0d6c4; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------------- responsive ---------------- */
@media (max-width: 820px) {
  /* Stack the layout; the sidebar becomes a sticky top bar with a
     horizontally-scrolling section nav so navigation stays available. */
  .layout { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .main { overflow: visible; }

  .sidebar {
    flex-direction: row; align-items: center; width: auto; flex: 0 0 auto;
    padding: 8px 12px; gap: 10px; position: sticky; top: 0; z-index: 30;
  }
  .sidebar-brand { padding: 0; flex: 0 0 auto; }
  .sidebar-title { display: none; }
  .sidebar-nav {
    flex-direction: row; gap: 4px; flex: 1; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: thin; padding-bottom: 2px;
  }
  .nav-item { white-space: nowrap; padding: 7px 11px; }
  .sidebar-foot { border: none; padding: 0; flex: 0 0 auto; }
  .sidebar-foot form { margin: 0; }
  .sidebar-foot .btn-block { width: auto; margin: 0; padding: 7px 12px; }
  .developed-by, .version { display: none; }

  .main-header { padding: 18px 16px 4px; }
  .body { padding: 12px 16px 24px; max-width: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  /* Let dense rows wrap instead of overflowing on narrow screens. */
  .person-row, .report-row, .report-row-top, .subsection-controls, .sqft-row,
  .photolog-row, .acronym-add { flex-wrap: wrap; }
  .person-row > select, .input-title { max-width: none; }

  .main-footer { flex-wrap: wrap; padding: 12px 16px; gap: 8px; }
  .main-footer .spacer { flex-basis: 100%; height: 0; }

  /* Wide modal grids scroll horizontally within the modal body. */
  .modal-body { overflow-x: auto; }
}
