/* ===== Site Daily Plan — Kamico palette ===== */
:root {
  --green: #435C4C;
  --green-dark: #33463A;
  --green-light: #5A7663;
  --cream: #E4E0D2;
  --cream-light: #F2F0E8;
  --paper: #FBFAF6;
  --ink: #26302A;
  --muted: #6E7A70;
  --border: #D8D4C6;
  --danger: #B3423A;
  --warn: #C9932B;
  --ok: #4C7A4F;
  --r: 12px;
  --shadow: 0 2px 10px rgba(38, 48, 42, .08);
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--cream-light);
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
}
button { font: inherit; cursor: pointer; color: inherit; background: none; border: none; }
input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
svg.lucide { width: 1.2em; height: 1.2em; stroke-width: 1.8; vertical-align: -.25em; }

/* ===== pages ===== */
.page { min-height: 100dvh; }
.page > .topbar + * { }

/* ===== login ===== */
#page-login {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--green) 0%, var(--green-dark) 100%);
  padding: 24px;
}
.login-box {
  background: var(--paper); border-radius: 16px; padding: 28px 24px;
  width: 100%; max-width: 360px; box-shadow: var(--shadow);
}
.login-logo {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  color: var(--green); font-weight: 700; font-size: 1.15rem; margin-bottom: 20px;
}
.login-logo svg { width: 26px; height: 26px; }
.login-hint { margin-top: 12px; text-align: center; color: var(--muted); font-size: .8rem; }

/* ===== fields ===== */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; min-height: 44px;
}
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--green-light); border-color: var(--green);
}

/* ===== buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 10px 16px; min-height: 44px; border-radius: 10px;
  font-weight: 600; transition: transform .15s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-ghost { border: 1px solid var(--border); background: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px; color: var(--green);
  transition: background .15s;
}
.icon-btn:hover { background: rgba(67, 92, 76, .1); }
.icon-btn.danger { color: var(--danger); }

/* ===== topbar ===== */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; min-height: 56px;
  position: sticky; top: 0; z-index: 20;
  background: var(--green); color: #fff;
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 1.05rem; font-weight: 700; flex: 1; }
.topbar .icon-btn { color: #fff; }
.topbar .icon-btn:hover { background: rgba(255,255,255,.12); }
.proj-progress { font-size: .85rem; font-weight: 600; padding-right: 8px; }

/* ===== projects grid ===== */
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px; padding: 16px; max-width: 900px; margin: 0 auto;
}
.project-card {
  background: var(--paper); border-radius: var(--r); padding: 16px;
  box-shadow: var(--shadow); cursor: pointer; text-align: left;
  transition: transform .15s; border: none; display: block; width: 100%;
}
.project-card:hover { transform: translateY(-2px); }
.project-card h3 { color: var(--green-dark); font-size: 1rem; margin-bottom: 4px; }
.project-card .pc-meta { color: var(--muted); font-size: .8rem; margin-bottom: 10px; }
.progress-track { height: 7px; border-radius: 4px; background: var(--cream); overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 4px; transition: width .3s; }

/* ===== app layout ===== */
#page-app { padding-bottom: 76px; } /* space for bottom nav */
.view { max-width: 900px; margin: 0 auto; padding: 14px 14px 90px; }

/* ===== date strip ===== */
.date-strip-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.date-strip-wrap::-webkit-scrollbar { display: none; }
.date-strip { display: flex; gap: 8px; padding: 4px 0 10px; }
.date-chip {
  flex: 0 0 auto; min-width: 56px; min-height: 46px; padding: 9px 6px; border-radius: 10px;
  background: #fff; border: 1px solid var(--border); text-align: center;
  transition: background .15s;
}
.date-chip .dc-dow { font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.date-chip .dc-num { font-size: 1.05rem; font-weight: 700; }
.date-chip.active { background: var(--green); color: #fff; border-color: var(--green); }
.date-chip.active .dc-dow { color: rgba(255,255,255,.75); }
.date-chip.today:not(.active) { border-color: var(--green); }
.date-chip .dc-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--warn); margin: 3px auto 0; }

.daily-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.daily-header h2 { font-size: 1rem; color: var(--green-dark); }
.daily-header .dh-sum { color: var(--muted); font-size: .82rem; margin-left: auto; }

/* ===== cards / list ===== */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--paper); border-radius: var(--r); padding: 14px;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .15s;
}
.card:active { transform: scale(.985); }
.card-top { display: flex; align-items: center; gap: 10px; }
.card-title { font-weight: 600; flex: 1; min-width: 0; }
.card-title .code { color: var(--muted); font-size: .78rem; font-weight: 600; display: block; }
.card-sub { color: var(--muted); font-size: .84rem; margin-top: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px;
  border-radius: 999px; font-size: .72rem; font-weight: 700;
}
.badge.b-done { background: rgba(76,122,79,.15); color: var(--ok); }
.badge.b-open { background: rgba(201,147,43,.15); color: var(--warn); }
.badge.b-late { background: rgba(179,66,58,.15); color: var(--danger); }
.badge.b-rev { background: rgba(67,92,76,.12); color: var(--green); }
.badge.b-note { background: rgba(67,92,76,.12); color: var(--green); }
.vol { font-weight: 700; font-variant-numeric: tabular-nums; }
.check-btn {
  width: 44px; height: 44px; border-radius: 10px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1.5px solid var(--border);
}
.check-btn.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.row-actions { display: flex; gap: 2px; }
.card .row-actions .icon-btn { width: 38px; height: 38px; }

/* empty state */
.empty {
  text-align: center; color: var(--muted); padding: 40px 16px;
  background: var(--paper); border-radius: var(--r); border: 1.5px dashed var(--border);
}
.empty svg { width: 34px; height: 34px; color: var(--green-light); margin-bottom: 8px; }

/* ===== FAB ===== */
.fab {
  position: fixed; right: 18px; bottom: 88px; width: 56px; height: 56px;
  border-radius: 50%; background: var(--green); color: #fff;
  box-shadow: 0 4px 14px rgba(51,70,58,.4); z-index: 30;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s;
}
.fab:active { transform: scale(.92); }
.fab svg { width: 26px; height: 26px; }

/* ===== bottom nav ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 25;
  display: flex; background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 7px; color: var(--muted); font-size: .68rem; font-weight: 600;
  min-height: 56px;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--green); }
.nav-btn.active svg { stroke-width: 2.2; }

/* ===== weekly grid ===== */
.week-nav { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; }
.week-label { font-weight: 700; color: var(--green-dark); font-size: .92rem; }
.week-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.week-grid { display: grid; min-width: 640px; gap: 4px; }
.wg-cell { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px 6px; }
.wg-head { background: var(--green); color: #fff; text-align: center; font-size: .72rem; font-weight: 700; padding: 7px 4px; }
.wg-head.today { background: var(--green-dark); }
.wg-head .wg-date { display: block; font-weight: 400; opacity: .8; font-size: .68rem; }
.wg-item { font-size: .8rem; font-weight: 600; color: var(--green-dark); padding: 8px 6px; background: var(--cream-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wg-input-cell { padding: 2px; }
.wg-input-cell input {
  width: 100%; min-height: 40px; border: none; text-align: center;
  background: transparent; font-variant-numeric: tabular-nums; font-size: .85rem;
}
.wg-input-cell input:focus { outline: 2px solid var(--green-light); border-radius: 6px; background: #fff; }
.wg-crew { width: 52px; font-size: .72rem; }
.wg-crew input { font-size: .75rem; }
.week-grid.locked .wg-input-cell input { color: var(--green-dark); }
.week-actions {
  display: flex; align-items: center; gap: 10px; margin-top: 14px;
  position: sticky; bottom: 0; padding: 10px 0;
}
.week-status { flex: 1; font-size: .8rem; color: var(--muted); }
.wg-note { grid-column: 1 / -1; font-size: .78rem; color: var(--muted); padding: 2px 6px; }

/* ===== BOQ ===== */
.boq-toolbar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.search-box {
  flex: 1; display: flex; align-items: center; gap: 8px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; min-height: 44px;
}
.search-box svg { color: var(--muted); flex: 0 0 auto; }
.search-box input { flex: 1; border: none; min-width: 0; background: transparent; min-height: 42px; }
.search-box input:focus { outline: none; }
.boq-item .card-top { align-items: flex-start; }
.boq-progress { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.boq-progress .progress-track { flex: 1; }
.boq-progress .bp-pct { font-size: .78rem; font-weight: 700; color: var(--green); font-variant-numeric: tabular-nums; }
.phase-tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: .72rem;
  background: var(--cream); color: var(--green-dark); padding: 2px 8px;
  border-radius: 999px; font-weight: 600; margin-right: 6px; margin-top: 6px;
}
.phase-tag svg { width: .95em; height: .95em; }
.note-ind { color: var(--green); display: inline-flex; align-items: center; gap: 3px; font-size: .75rem; font-weight: 600; }
.note-ind svg { width: 1em; height: 1em; }

/* import preview */
.xpv-meta { font-size: .82rem; color: var(--muted); margin-bottom: 10px; }
.col-map { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.xpv-rows { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; }
.xpv-row { display: grid; grid-template-columns: 60px 1fr 60px 55px; gap: 6px; padding: 7px 10px; font-size: .82rem; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.xpv-row:last-child { border-bottom: none; }
.xpv-row.hd { background: var(--cream-light); font-weight: 700; font-size: .72rem; text-transform: uppercase; color: var(--muted); }

/* ===== segments (gantt toggle) ===== */
.seg {
  display: flex; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 3px; margin-bottom: 12px;
}
.seg-btn {
  flex: 1; min-height: 40px; border-radius: 8px; font-weight: 600; font-size: .88rem;
  color: var(--muted); transition: background .15s, color .15s;
}
.seg-btn.active { background: var(--green); color: #fff; }

/* ===== gantt ===== */
.gantt-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gantt { min-width: max-content; }
.g-grid { display: grid; }
.g-head-cell {
  font-size: .68rem; font-weight: 600; color: var(--muted); text-align: center;
  padding: 6px 0; border-bottom: 1px solid var(--border); background: #fff;
  position: sticky; top: 0;
}
.g-head-cell.today { color: var(--green); font-weight: 800; box-shadow: inset 0 0 0 1.5px var(--green); border-radius: 6px; }
.g-name {
  position: sticky; left: 0; z-index: 2; background: var(--paper);
  font-size: .78rem; font-weight: 600; color: var(--green-dark);
  padding: 6px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-bottom: 1px solid var(--border); min-width: 150px; max-width: 170px;
  display: flex; align-items: center; gap: 6px;
}
.g-name .gn-code { color: var(--muted); font-size: .68rem; }
.g-name .gn-arrow { color: var(--muted); flex: 0 0 auto; }
.g-row-cell { border-bottom: 1px solid var(--cream); position: relative; min-height: 34px; }
.g-row-cell.today-col { background: rgba(67,92,76,.06); }
.g-bar {
  position: absolute; top: 7px; height: 20px; border-radius: 5px;
  background: var(--green-light); min-width: 8px;
}
.g-bar .g-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--green); border-radius: 5px;
}
.g-bar.phase-b { background: #8FA896; }
.g-bar.phase-a { }
.g-vol { position: absolute; top: 7px; font-size: .62rem; font-weight: 700; color: var(--green-dark); background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 1px 4px; white-space: nowrap; }
.g-today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); z-index: 3; pointer-events: none; }
.g-legend { display: flex; gap: 14px; padding: 10px 2px; font-size: .75rem; color: var(--muted); flex-wrap: wrap; }
.g-legend .lg-item { display: inline-flex; align-items: center; gap: 6px; }
.g-legend .lg-swatch { width: 14px; height: 10px; border-radius: 3px; }

/* ===== sheets ===== */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(38,48,42,.45); z-index: 40;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--paper); border-radius: 18px 18px 0 0;
  max-height: 88dvh; overflow-y: auto; padding: 18px 18px 30px;
  transform: translateY(100%); transition: transform .25s cubic-bezier(.16,1,.3,1);
  box-shadow: 0 -6px 30px rgba(38,48,42,.2);
}
.sheet.open { transform: translateY(0); }
.sheet-close { position: absolute; top: 10px; right: 10px; }
.sheet h2 { font-size: 1.05rem; color: var(--green-dark); margin-bottom: 14px; padding-right: 40px; }
.sheet h3 { font-size: .88rem; color: var(--green-dark); margin: 16px 0 8px; }
.sheet .btn-block { margin-top: 6px; }

/* item detail */
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.dm-box { background: var(--cream-light); border-radius: 10px; padding: 10px 12px; }
.dm-box .dm-label { font-size: .7rem; color: var(--muted); font-weight: 600; }
.dm-box .dm-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.phase-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px;
}
.phase-row .progress-track { flex: 1; }
.note-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.note-card .nc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.note-card .nc-date { color: var(--muted); font-size: .75rem; margin-left: auto; }
.note-card p { font-size: .88rem; white-space: pre-wrap; }
.note-card.instruction { border-left: 3px solid var(--warn); }
.note-photos { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.note-photos img {
  width: 72px; height: 72px; object-fit: cover; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border);
}
.photo-input-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.photo-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.photo-thumbs .pt-wrap { position: relative; }
.photo-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.photo-thumbs .pt-del {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--danger); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.photo-thumbs .pt-del svg { width: 13px; height: 13px; }

/* photo viewer */
.photo-viewer {
  position: fixed; inset: 0; z-index: 50; background: rgba(20,25,21,.92);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.photo-viewer img { max-width: 96vw; max-height: 92dvh; border-radius: 8px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: .85rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== desktop ===== */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .fab { bottom: 24px; }
  #page-app { padding-bottom: 0; }
  .view { padding-bottom: 40px; }
  .sheet { max-width: 560px; left: 50%; transform: translate(-50%, 100%); border-radius: 16px; bottom: 10vh; }
  .sheet.open { transform: translate(-50%, 0); }
  /* sidebar layout */
  .app-topbar { position: static; }
  .sheet-backdrop { z-index: 40; }
}
@media (min-width: 900px) {
  #page-app { display: flex; }
  .app-side {
    width: 200px; flex: 0 0 auto; background: var(--green); color: #fff;
    padding-top: 14px; min-height: calc(100dvh); display: flex; flex-direction: column; gap: 2px;
  }
  .app-side .side-brand { padding: 6px 16px 14px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
  .side-btn {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px; color: rgba(255,255,255,.75);
    font-weight: 600; font-size: .88rem; min-height: 44px;
  }
  .side-btn.active { background: var(--green-dark); color: #fff; }
  .app-main { flex: 1; min-width: 0; }
  .app-main .app-topbar { background: transparent; color: var(--ink); box-shadow: none; border-bottom: 1px solid var(--border); }
  .app-main .app-topbar h1 { color: var(--green-dark); }
  .app-main .app-topbar .icon-btn { color: var(--green); }
  .app-main .app-topbar .icon-btn:hover { background: rgba(67,92,76,.1); }
}

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