/* ===========================================================================
   QuantumEdge — dark, Linear-inspired design system
   Recreated from the Claude Design handoff; wired to the PHP JSON API.
   =========================================================================== */
:root {
  /* Surfaces — near-black neutrals, very low chroma */
  --bg:            #08090a;
  --bg-1:          #0d0e10;
  --surface:       #111214;
  --surface-2:     #161719;
  --surface-3:     #1c1d20;
  --elevated:      #202024;
  --overlay-scrim: rgba(0,0,0,.55);

  /* Borders / hairlines */
  --border:        rgba(255,255,255,.07);
  --border-2:      rgba(255,255,255,.10);
  --border-strong: rgba(255,255,255,.16);

  /* Text */
  --text:          #f7f8f8;
  --text-2:        #d0d2d6;
  --text-3:        #8a8f98;
  --text-4:        #62666d;

  /* Accent — Linear indigo */
  --accent:        #5e6ad2;
  --accent-hover:  #6f7ae0;
  --accent-soft:   rgba(94,106,210,.16);
  --accent-line:   rgba(94,106,210,.45);
  --accent-text:   #b0b6f2;

  /* Status hues */
  --s-backlog:  #8a8f98;
  --s-ready:    #95a3b8;
  --s-progress: #f2c94c;
  --s-qa:       #e8943a;
  --s-uat:      #b07ce8;
  --s-prod:     #4ea7f0;
  --s-done:     #4cb782;

  /* Priority */
  --p-urgent:   #eb5757;
  --p-high:     #e8943a;

  --radius:    6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 4px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.4);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  --sidebar-w: 244px;
  --ease: cubic-bezier(.32,.72,0,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; color-scheme: dark; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.01em;
  overflow: hidden;
}
#root { height: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--accent-soft); }
.hidden { display: none !important; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.16); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-corner { background: transparent; }

/* ===========================================================================
   App shell
   =========================================================================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100%; }

/* ---- Sidebar ------------------------------------------------------------ */
.sidebar {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.ws-head {
  display: flex; align-items: center; gap: 9px;
  padding: 13px 14px; height: 49px;
  cursor: default; border-radius: 8px; margin: 7px 8px 2px;
}
.ws-logo {
  width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0;
  background: linear-gradient(150deg, #6f7ae0, #4b56b8);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 1px 3px rgba(0,0,0,.4);
}
.ws-name { font-weight: 600; font-size: 13.5px; color: var(--text); letter-spacing: -.02em; }
.ws-chev { margin-left: auto; color: var(--text-4); }

.side-search {
  margin: 6px 10px 8px; display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: 7px; background: var(--surface-2);
  border: 1px solid transparent; color: var(--text-3); font-size: 12.5px;
  transition: border-color .12s, background .12s; width: calc(100% - 20px); text-align: left;
}
.side-search:hover { background: var(--surface-3); }
.side-search .ss-label { flex: 1; }
.side-search .kbd { margin-left: auto; }

.nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; min-height: 0; }
.nav-section { margin-top: 14px; }
.nav-section-head {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 9px; color: var(--text-4);
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  user-select: none;
}
.nav-section-head .sec-add { margin-left: auto; opacity: 0; color: var(--text-3); border-radius: 4px; padding: 1px; display: grid; place-items: center; border: none; background: none; }
.nav-section-head:hover .sec-add { opacity: 1; }
.nav-section-head .sec-add:hover { background: var(--surface-3); color: var(--text); }

.client-group { margin-bottom: 2px; }
.client-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 9px; border-radius: 7px; cursor: pointer; user-select: none;
  color: var(--text-3); font-size: 12.5px; font-weight: 500;
}
.client-row:hover { background: var(--surface-2); color: var(--text-2); }
.client-row .caret { transition: transform .15s var(--ease); color: var(--text-4); display: grid; place-items: center; }
.client-row.collapsed .caret { transform: rotate(-90deg); }
.client-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.client-row .cl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.project-list { margin: 1px 0 3px; }
.project-item {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 9px 5px 26px; border-radius: 7px; cursor: pointer; user-select: none;
  color: var(--text-2); font-size: 13px; position: relative;
  transition: background .1s, color .1s;
}
.project-item:hover { background: var(--surface-2); color: var(--text); }
.project-item.active { background: var(--accent-soft); color: var(--text); }
.project-item.active::before {
  content: ""; position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 2px; height: 13px; border-radius: 2px; background: var(--accent);
}
.project-item .p-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item .p-count { margin-left: auto; font-size: 11px; color: var(--text-4); font-variant-numeric: tabular-nums; }
.project-item.active .p-count { color: var(--accent-text); }
.project-item.editing { background: transparent; cursor: default; }

.row-icon, .row-add {
  opacity: 0; border: none; background: none; color: var(--text-3);
  padding: 1px; border-radius: 4px; display: grid; place-items: center; flex-shrink: 0;
  transition: opacity .12s, background .12s, color .12s;
}
.client-row:hover .row-icon, .project-item:hover .row-icon { opacity: .8; }
.client-row:hover .row-add { opacity: 1; }
.row-icon:hover, .row-add:hover { opacity: 1; background: var(--surface-3); color: var(--text); }
.project-item.active .row-icon { color: var(--accent-text); }

.side-input {
  width: calc(100% - 18px); margin: 3px 0 3px 9px; padding: 6px 9px;
  background: var(--surface-2); border: 1px solid var(--accent-line); border-radius: 7px;
  color: var(--text); font-size: 12.5px; outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.side-input::placeholder { color: var(--text-4); }
.client-row .side-input, .project-item .side-input { flex: 1; width: auto; margin: 0; }
.side-empty { padding: 14px 12px; color: var(--text-4); font-size: 12.5px; }

.side-foot { border-top: 1px solid var(--border); padding: 8px; display: flex; align-items: center; gap: 9px; position: relative; }
.avatar {
  border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  font-weight: 600; color: #fff; font-size: 11px; letter-spacing: 0;
  width: 26px; height: 26px; background: var(--accent);
}
.side-foot .who { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.side-foot .who b { font-size: 12.5px; font-weight: 550; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { font-size: 11px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .foot-btn { color: var(--text-3); padding: 6px; border-radius: 6px; background: none; border: none; display: grid; place-items: center; }
.side-foot .foot-btn:hover { background: var(--surface-2); color: var(--text); }
.acct-menu { position: absolute; left: 10px; right: 10px; bottom: 54px; min-width: 0; }

/* ---- Main --------------------------------------------------------------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-1); }

.topbar {
  display: flex; align-items: center; gap: 12px;
  height: 49px; padding: 0 16px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.crumb { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumb .client { color: var(--text-3); font-size: 13px; font-weight: 450; }
.crumb .sep { color: var(--text-4); display: grid; place-items: center; }
.crumb .title { color: var(--text); font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.crumb .p-icon { color: var(--text-2); display: grid; place-items: center; }

.seg { display: flex; gap: 2px; background: var(--surface-2); padding: 2px; border-radius: 8px; }
.seg button {
  display: flex; align-items: center; gap: 6px;
  border: none; background: transparent; color: var(--text-3);
  font-size: 12.5px; font-weight: 500; padding: 5px 11px; border-radius: 6px;
  transition: background .12s, color .12s;
}
.seg button:hover { color: var(--text-2); }
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button svg { color: currentColor; }

.topbar .spacer { flex: 1; }
.tb-btn {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2);
  font-size: 12.5px; font-weight: 500; padding: 6px 11px; border-radius: 7px;
  transition: background .12s, border-color .12s, color .12s;
}
.tb-btn:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.tb-btn.icon { padding: 6px; }
.tb-btn.primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.tb-btn.primary:hover { background: var(--accent-hover); }

.kbd {
  display: inline-flex; align-items: center; gap: 1px;
  font-family: var(--font); font-size: 11px; font-weight: 500; color: var(--text-3);
  background: rgba(255,255,255,.06); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; line-height: 1.4;
}

/* ---- Board -------------------------------------------------------------- */
.board-wrap { flex: 1; overflow: auto; min-height: 0; }
.board { display: flex; gap: 0; padding: 0 4px; height: 100%; align-items: stretch; min-width: max-content; }
.col {
  width: 312px; flex-shrink: 0; display: flex; flex-direction: column;
  padding: 12px 8px; min-height: 0;
}
.col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 10px; flex-shrink: 0;
}
.col-head .c-name { font-weight: 600; font-size: 12.5px; color: var(--text); letter-spacing: -.01em; white-space: nowrap; flex-shrink: 0; }
.col-head .c-count { color: var(--text-4); font-size: 12px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.col-head .c-add { margin-left: auto; color: var(--text-3); padding: 3px; border-radius: 5px; background: none; border: none; display: grid; place-items: center; opacity: 0; transition: opacity .12s, background .12s; }
.col:hover .c-add { opacity: 1; }
.col-head .c-add:hover { background: var(--surface-3); color: var(--text); }

.col-cards { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; min-height: 0; padding: 2px; }
.col-cards.drag-over { background: var(--accent-soft); border-radius: 10px; outline: 1px dashed var(--accent-line); }

.card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 11px 12px 10px;
  cursor: pointer; user-select: none;
  transition: border-color .12s, background .12s, transform .08s, box-shadow .12s;
  will-change: transform;
}
.card:hover { border-color: var(--border-strong); background: var(--surface-3); }
.card:active { cursor: grabbing; }
.card.dragging { opacity: .35; }
.card.lifted { box-shadow: var(--shadow-lg); border-color: var(--accent-line); transform: rotate(1.5deg); }

.card-top { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.card-id { font-family: var(--mono); font-size: 11px; color: var(--text-4); letter-spacing: 0; font-weight: 500; white-space: nowrap; }
.card-top .grow { flex: 1; }
.card-title { font-size: 13.5px; line-height: 1.4; color: var(--text); font-weight: 450; word-break: break-word; }

.card-foot { display: flex; align-items: center; gap: 13px; margin-top: 11px; color: var(--text-4); font-size: 11.5px; }
.card-foot .mi { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.card-foot .mi svg { width: 13px; height: 13px; }
.card-foot .push { margin-left: auto; }

.drop-line { height: 2px; background: var(--accent); border-radius: 2px; margin: -3px 2px; box-shadow: 0 0 6px var(--accent-line); }

.add-card-btn {
  display: flex; align-items: center; gap: 7px; width: 100%;
  background: transparent; border: 1px dashed transparent; color: var(--text-4);
  font-size: 12.5px; font-weight: 450; padding: 7px 9px; border-radius: 9px;
  transition: background .12s, color .12s; margin-top: 2px;
}
.add-card-btn:hover { background: var(--surface-2); color: var(--text-2); }

.col-compose textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg); color: var(--text); font-family: inherit;
  font-size: 13.5px; padding: 10px 12px; resize: none; outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.col-compose .hint { display: flex; gap: 8px; align-items: center; margin-top: 6px; color: var(--text-4); font-size: 11px; padding: 0 2px; }

/* ===========================================================================
   Card detail — right slide-over
   =========================================================================== */
.scrim {
  position: fixed; inset: 0; background: var(--overlay-scrim);
  backdrop-filter: blur(2px); z-index: 40; opacity: 1;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }

.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 88vw);
  background: var(--surface); border-left: 1px solid var(--border-2);
  z-index: 41; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateX(0); animation: slidein .32s var(--ease);
}
@keyframes slidein { from { transform: translateX(100%); } }

.panel-bar {
  display: flex; align-items: center; gap: 10px; height: 49px;
  padding: 0 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.panel-bar .p-crumb { display: flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12.5px; }
.panel-bar .p-crumb .id { font-family: var(--mono); font-size: 12px; }
.panel-bar .spacer { flex: 1; }
.ip { color: var(--text-3); background: none; border: none; padding: 6px; border-radius: 6px; display: grid; place-items: center; }
.ip:hover { background: var(--surface-2); color: var(--text); }
.ip.danger:hover { background: rgba(235,87,87,.14); color: #e87b7b; }

.panel-body { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 264px; min-height: 0; }
.panel-main { padding: 26px 30px; min-width: 0; }
.panel-side { border-left: 1px solid var(--border); padding: 22px 20px; background: var(--bg-1); display: flex; flex-direction: column; gap: 20px; }

.detail-title { font-size: 21px; font-weight: 600; color: var(--text); letter-spacing: -.02em; line-height: 1.3; margin: 0 0 18px; border: none; background: none; width: 100%; padding: 0; resize: none; font-family: inherit; outline: none; }

.section-label { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; display: flex; align-items: center; }
.section-label .lbl-total { margin-left: auto; color: var(--accent-text); font-family: var(--mono); text-transform: none; letter-spacing: 0; }

.md { color: var(--text-2); font-size: 14px; line-height: 1.65; }
.md h1,.md h2,.md h3 { color: var(--text); font-weight: 600; letter-spacing: -.01em; margin: 1.3em 0 .5em; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16px; } .md h3 { font-size: 14.5px; }
.md p { margin: .55em 0; }
.md ul, .md ol { padding-left: 20px; margin: .5em 0; }
.md li { margin: .25em 0; }
.md code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--surface-3); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: .7em 0; }
.md pre code { background: none; border: none; padding: 0; font-size: 12.5px; color: var(--text-2); }
.md a { color: var(--accent-text); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md strong { color: var(--text); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md input[type=checkbox] { accent-color: var(--accent); margin-right: 7px; }
.md h4,.md h5,.md h6 { color: var(--text); font-weight: 600; letter-spacing: -.01em; margin: 1.1em 0 .5em; font-size: 13.5px; }
.md em { font-style: italic; }
.md del { color: var(--text-4); }
.md blockquote { margin: .7em 0; padding: 2px 14px; border-left: 2px solid var(--border-strong); color: var(--text-3); }
.md img { max-width: 100%; border-radius: 8px; }
.md table { border-collapse: collapse; margin: .7em 0; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; color: var(--text); }
.md ul ul, .md ol ol, .md ul ol, .md ol ul { margin: .25em 0; }

/* description editor (inline) */
.desc-edit textarea {
  width: 100%; min-height: 130px; background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: 9px; color: var(--text-2); font-family: var(--mono); font-size: 13px; line-height: 1.7;
  padding: 12px 14px; resize: vertical; outline: none;
}
.desc-edit textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.desc-view { cursor: text; }
.desc-view .desc-empty { color: var(--text-4); font-size: 14px; }
.desc-actions { display: flex; gap: 8px; margin-top: 10px; }

/* meta rows (side) */
.meta-row { display: flex; flex-direction: column; gap: 7px; }
.meta-row > .k { font-size: 11.5px; color: var(--text-3); font-weight: 500; }
.meta-pill {
  display: inline-flex; align-items: center; gap: 7px; align-self: flex-start;
  padding: 4px 9px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); font-size: 12.5px; font-weight: 500; white-space: nowrap;
}
.meta-pill:hover { background: var(--surface-3); border-color: var(--border-2); }
.meta-divider { border-top: 1px solid var(--border); }

.attach-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
}
.attach-item .ai { width: 30px; height: 30px; border-radius: 6px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); flex-shrink: 0; }
.attach-item .an { font-size: 12.5px; color: var(--text); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.attach-item a.an:hover { color: var(--accent-text); }
.attach-item .as { font-size: 11px; color: var(--text-4); flex-shrink: 0; }
.attach-item .attach-x { opacity: 0; background: none; border: none; color: var(--text-3); padding: 4px; border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; transition: opacity .12s, background .12s, color .12s; }
.attach-item:hover .attach-x { opacity: 1; }
.attach-item .attach-x:hover { background: rgba(235,87,87,.14); color: #e87b7b; }

.dropzone {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px; padding: 14px; border: 1px dashed var(--border-strong);
  border-radius: 9px; color: var(--text-3); font-size: 12.5px; cursor: pointer;
  background: var(--surface-2); transition: border-color .12s, background .12s, color .12s;
}
.dropzone:hover { border-color: var(--accent-line); color: var(--text-2); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); border-style: solid; }
.dropzone .dz-link { color: var(--accent-text); font-weight: 500; }

.comment-row { padding: 2px 0; }
.comment-row .cmeta { margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.comment-row .cmeta time { font-size: 11px; color: var(--text-4); }
.comment-row .ctext { font-size: 13px; color: var(--text-2); line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.comment-row .cdel { opacity: 0; border: none; background: none; color: var(--text-4); padding: 2px; border-radius: 5px; display: grid; place-items: center; transition: opacity .12s, background .12s, color .12s; }
.comment-row:hover .cdel { opacity: 1; }
.comment-row .cdel:hover { background: rgba(235,87,87,.14); color: #e87b7b; }

.composer { display: flex; gap: 11px; margin-top: 14px; }
.composer .cbox { flex: 1; }
.composer textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-family: inherit; font-size: 13px;
  padding: 9px 11px; resize: none; outline: none; transition: border-color .12s; min-height: 60px;
}
.composer textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer .cact { display: flex; justify-content: flex-end; margin-top: 8px; }

.btn {
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2);
  font-size: 12.5px; font-weight: 500; padding: 6px 12px; border-radius: 7px; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: #e87b7b; }
.btn.danger:hover { background: rgba(235,87,87,.12); color: #f09c9c; border-color: rgba(235,87,87,.3); }
.btn:disabled { opacity: .5; cursor: default; }

/* ===========================================================================
   Timesheet
   =========================================================================== */
.sheet-wrap { flex: 1; overflow: auto; padding: 22px 24px 40px; min-height: 0; }
.sheet-filters { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.sheet-filters .fl { display: flex; flex-direction: column; gap: 5px; }
.sheet-filters .fl span { font-size: 11px; color: var(--text-3); font-weight: 500; padding-left: 2px; }
.sheet-filters input, .sheet-filters select {
  background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
  border-radius: 7px; padding: 7px 10px; font-size: 12.5px; outline: none;
}
.sheet-filters input:focus, .sheet-filters select:focus { border-color: var(--accent-line); }
.sheet-filters .total { margin-left: auto; text-align: right; }
.sheet-filters .total .tn { font-size: 22px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.sheet-filters .total .tl { font-size: 11px; color: var(--text-3); }

.sheet-scroll { border: 1px solid var(--border); border-radius: var(--radius-xl); overflow: auto; background: var(--surface); }
table.sheet { border-collapse: collapse; width: 100%; }
table.sheet th, table.sheet td { padding: 10px 14px; text-align: right; font-size: 12.5px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.sheet thead th { background: var(--surface-2); color: var(--text-3); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; z-index: 2; }
table.sheet th:first-child, table.sheet td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 280px; }
table.sheet thead th:first-child { z-index: 3; background: var(--surface-2); }
table.sheet td:first-child { color: var(--text); font-weight: 450; }
table.sheet td .tid { font-family: var(--mono); font-size: 11px; color: var(--text-4); margin-right: 8px; }
table.sheet tbody tr:hover td { background: var(--surface-2); }
table.sheet tbody tr:hover td:first-child { background: var(--surface-2); }
table.sheet td.zero { color: var(--text-4); }
table.sheet td.val { color: var(--text-2); }
table.sheet tfoot td { font-weight: 600; color: var(--text); background: var(--surface-2); position: sticky; bottom: 0; }
table.sheet tfoot td:first-child { background: var(--surface-2); }
table.sheet .colhrs { color: var(--accent-text); }

/* ===========================================================================
   Time entries table (card detail)
   =========================================================================== */
.te-table { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.te-table table { width: 100%; border-collapse: collapse; }
.te-table th, .te-table td { padding: 9px 14px; font-size: 13px; text-align: left; border-bottom: 1px solid var(--border); }
.te-table th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); }
.te-table th.r, .te-table td.r { text-align: right; }
.te-table td { color: var(--text-2); }
.te-table .te-h { font-family: var(--mono); color: var(--accent-text); font-size: 12.5px; }
.te-table .te-note { color: var(--text-3); }
.te-table tbody tr:hover td { background: var(--surface-2); }
.te-table .te-empty { color: var(--text-4); text-align: center; padding: 18px; }
.te-table tfoot td { font-weight: 600; color: var(--text); background: var(--surface-2); border-bottom: none; }
.te-table .te-x { opacity: 0; border: none; background: none; color: var(--text-4); padding: 3px; border-radius: 5px; display: inline-grid; place-items: center; transition: opacity .12s, background .12s, color .12s; }
.te-table tbody tr:hover .te-x { opacity: 1; }
.te-table .te-x:hover { background: rgba(235,87,87,.14); color: #e87b7b; }
.te-form { display: flex; gap: 8px; padding: 10px 12px; background: var(--surface-2); border-top: 1px solid var(--border); }
.te-form input { background: var(--surface); border: 1px solid var(--border-2); color: var(--text); border-radius: 7px; padding: 7px 10px; font-size: 12.5px; outline: none; }
.te-form input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.te-form .hh { width: 76px; }
.te-form .dd { width: 140px; }
.te-form .nn { flex: 1; min-width: 0; }

.time-stat { display: flex; align-items: baseline; gap: 6px; }
.time-stat .tn { font-size: 26px; font-weight: 600; color: var(--text); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.time-stat .tu { font-size: 12.5px; color: var(--text-3); }
.time-stat .tc { font-size: 11.5px; color: var(--text-4); margin-left: 2px; }

/* ===========================================================================
   Command palette
   =========================================================================== */
.cmd-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(3px);
  z-index: 60; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 14vh; opacity: 1; animation: fade .12s ease;
}
.cmd {
  width: min(640px, 92vw); background: var(--elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); overflow: hidden;
  transform: scale(1); animation: pop .16s var(--ease);
}
@keyframes pop { from { transform: scale(.97); } }
.cmd-input-row { display: flex; align-items: center; gap: 11px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.cmd-input-row svg { color: var(--text-3); flex-shrink: 0; }
.cmd-input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-family: inherit; font-size: 15px; }
.cmd-input::placeholder { color: var(--text-4); }
.cmd-list { max-height: 380px; overflow-y: auto; padding: 7px; }
.cmd-group-label { padding: 9px 11px 5px; font-size: 11px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: .04em; }
.cmd-row {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 8px;
  color: var(--text-2); font-size: 13.5px; cursor: pointer;
}
.cmd-row .ci { color: var(--text-3); display: grid; place-items: center; width: 18px; }
.cmd-row.active { background: var(--accent-soft); color: var(--text); }
.cmd-row.active .ci { color: var(--accent-text); }
.cmd-row .ck { margin-left: auto; }
.cmd-row .csub { color: var(--text-4); font-size: 12px; margin-left: 8px; }
.cmd-empty { padding: 28px; text-align: center; color: var(--text-4); font-size: 13px; }

/* ===========================================================================
   Empty state
   =========================================================================== */
.empty { flex: 1; display: grid; place-items: center; }
.empty-card { text-align: center; max-width: 360px; }
.empty-ill { width: 56px; height: 56px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; margin: 0 auto 18px; color: var(--text-3); }
.empty-card h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0 0 6px; letter-spacing: -.01em; }
.empty-card p { font-size: 13px; color: var(--text-3); margin: 0 0 18px; line-height: 1.5; }

/* status icon sizing */
.sicon { flex-shrink: 0; display: grid; place-items: center; }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(0);
  background: var(--elevated); color: var(--text); border: 1px solid var(--border-strong);
  padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); z-index: 80;
  font-size: 12.5px; opacity: 1; animation: toastin .2s var(--ease);
  display: flex; align-items: center; gap: 9px;
}
@keyframes toastin { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

.menu {
  position: fixed; background: var(--elevated); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; z-index: 70; min-width: 180px;
}
.menu-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--text-2); font-size: 13px; cursor: pointer; }
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item.danger { color: #e87b7b; }
.menu-item.danger:hover { background: rgba(235,87,87,.12); color: #f09c9c; }
.menu-item svg { color: var(--text-3); }
.menu-item.danger svg { color: #e87b7b; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

.fade-up { animation: fadeUp .3s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===========================================================================
   Knowledge Base
   =========================================================================== */
.kb { flex: 1; display: flex; min-height: 0; }
.kb-list { width: 290px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.kb-list-head { display: flex; align-items: center; gap: 6px; padding: 15px 12px 9px 16px; }
.kb-list-head .t { font-weight: 600; font-size: 13px; color: var(--text); }
.kb-list-head .sp { flex: 1; }
.kb-hbtn { border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2); border-radius: 7px; padding: 5px; display: grid; place-items: center; transition: background .12s, border-color .12s, color .12s; }
.kb-hbtn:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.kb-hbtn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.kb-hbtn.primary:hover { background: var(--accent-hover); }

.kb-items { flex: 1; overflow-y: auto; padding: 4px 8px 14px; display: flex; flex-direction: column; gap: 1px; position: relative; }
.kb-items.dragging { outline: 1px dashed var(--accent-line); outline-offset: -6px; background: var(--accent-soft); border-radius: 10px; }
.kb-group-label { padding: 12px 9px 4px; font-size: 11px; font-weight: 600; color: var(--text-4); text-transform: uppercase; letter-spacing: .04em; }
.kb-list-empty { padding: 24px 12px; color: var(--text-4); font-size: 12.5px; text-align: center; }
.kb-drop-hint { position: absolute; inset: 6px; border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--accent-text); font-size: 13px; font-weight: 500; pointer-events: none; background: rgba(94,106,210,.06); }

.kb-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background .1s; }
.kb-item:hover { background: var(--surface-2); }
.kb-item.active { background: var(--surface-3); }
.kb-item .ic { color: var(--text-3); margin-top: 1px; flex-shrink: 0; display: grid; place-items: center; }
.kb-item.active .ic { color: var(--accent-text); }
.kb-item .meta { min-width: 0; flex: 1; }
.kb-item .nm { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-item .sub { font-size: 11px; color: var(--text-4); margin-top: 2px; }
.kb-item .del { opacity: 0; border: none; background: none; color: var(--text-4); padding: 3px; border-radius: 5px; display: grid; place-items: center; flex-shrink: 0; transition: opacity .12s, background .12s, color .12s; }
.kb-item:hover .del { opacity: 1; }
.kb-item .del:hover { background: rgba(235,87,87,.14); color: #e87b7b; }

.kb-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.kb-doc-head { padding: 24px 36px 0; }
.kb-doc-title { width: 100%; border: none; background: none; outline: none; color: var(--text); font-family: inherit; font-size: 24px; font-weight: 600; letter-spacing: -.02em; padding: 0; }
.kb-doc-title::placeholder { color: var(--text-4); }
.kb-doc-bar { display: flex; align-items: center; gap: 10px; padding: 16px 36px; border-bottom: 1px solid var(--border); }
.kb-doc-bar .saved { font-size: 11.5px; color: var(--text-4); }
.kb-editor { flex: 1; overflow-y: auto; padding: 24px 36px 60px; }
.kb-editor .kb-textarea { width: 100%; min-height: 360px; background: transparent; border: none; outline: none; color: var(--text-2); font-family: var(--mono); font-size: 13.5px; line-height: 1.75; resize: none; }
.kb-editor .kb-textarea::placeholder { color: var(--text-4); }
.kb-preview { max-width: 760px; }
.kb-preview.md { font-size: 14.5px; }

.kb-file { flex: 1; display: grid; place-items: center; padding: 40px; }
.kb-file-card { text-align: center; max-width: 360px; }
.kb-file-icon { width: 64px; height: 64px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--text-3); margin: 0 auto 18px; }
.kb-file-name { font-size: 16px; font-weight: 600; color: var(--text); letter-spacing: -.01em; word-break: break-all; }
.kb-file-sub { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }

/* ===========================================================================
   Auth — login & change password
   =========================================================================== */
.auth-screen {
  height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(94,106,210,.16), transparent 60%),
    var(--bg);
}
.auth-logo {
  border-radius: 11px; display: grid; place-items: center; margin: 0 auto 20px;
  background: linear-gradient(150deg, #6f7ae0, #4b56b8);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 4px 16px rgba(0,0,0,.4);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg); padding: 34px 32px 28px; text-align: center;
}
.auth-card h1 { font-size: 19px; font-weight: 600; color: var(--text); letter-spacing: -.02em; margin: 0 0 5px; }
.auth-card .auth-sub { font-size: 13px; color: var(--text-3); margin: 0 0 24px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; text-align: left; margin-bottom: 14px; }
.auth-field span { font-size: 12px; font-weight: 500; color: var(--text-2); }
.auth-field input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font-size: 13.5px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.auth-field input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-field input::placeholder { color: var(--text-4); }
.auth-error { display: flex; align-items: center; gap: 6px; color: #f09c9c; font-size: 12.5px; margin: 2px 0 12px; text-align: left; }
.auth-submit { width: 100%; justify-content: center; padding: 10px; font-size: 13.5px; margin-top: 4px; }
.auth-hint { margin-top: 18px; font-size: 11.5px; color: var(--text-4); }
.auth-hint code { font-family: var(--mono); color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-size: 11px; }

.auth-modal {
  width: min(420px, 92vw); background: var(--elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 22px 24px 20px;
  transform: scale(1); animation: pop .16s var(--ease);
}
.auth-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.auth-modal-head h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; letter-spacing: -.01em; }
.auth-modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ===========================================================================
   Modal / bottom sheet (settings, change password)
   =========================================================================== */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(3px);
  z-index: 65; display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .12s ease;
}
.sheet {
  width: min(420px, 92vw); background: var(--elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: 22px 24px 20px;
  animation: pop .16s var(--ease);
}
.sheet-handle { display: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.sheet-head h3 { font-size: 16px; font-weight: 600; color: var(--text); margin: 0; letter-spacing: -.01em; }
.sheet-foot { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.sheet-foot .right { margin-left: auto; display: flex; gap: 8px; }
.sheet-confirm { font-size: 12.5px; color: var(--text-3); margin: 2px 0 0; line-height: 1.5; }
@keyframes sheetup { from { transform: translateY(100%); } }

/* ===========================================================================
   Responsive drawer
   =========================================================================== */
.nav-toggle { display: none; place-items: center; border: none; background: none; color: var(--text-2); padding: 6px; border-radius: 7px; margin-right: 2px; flex-shrink: 0; }
.nav-toggle:hover { background: var(--surface-2); color: var(--text); }
.nav-scrim { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: 280px; z-index: 46;
    transform: translateX(-100%); transition: transform .28s var(--ease);
    box-shadow: var(--shadow-lg); border-right: 1px solid var(--border-2);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); backdrop-filter: blur(2px); z-index: 45; }
  .nav-toggle { display: grid; }
  .kb { flex-direction: column; }
  .kb-list { width: 100%; max-height: 230px; border-right: none; border-bottom: 1px solid var(--border); }
  .kb-doc-head, .kb-doc-bar, .kb-editor { padding-left: 20px; padding-right: 20px; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 10px; gap: 8px; overflow-x: auto; }
  .crumb .client, .crumb .sep, .crumb .p-icon { display: none; }
  .crumb .title { font-size: 14px; }
  .seg button { font-size: 0; padding: 6px 9px; }
  .seg button svg { width: 15px; height: 15px; }
  .tb-btn.primary { font-size: 0; padding: 7px; gap: 0; }
  .tb-btn.primary svg { width: 16px; height: 16px; }
  .panel { width: 100vw; }
  .panel-body { display: block; }
  .panel-side { border-left: none; border-top: 1px solid var(--border); }
  .panel-main { padding: 22px 20px; }
  .sheet-filters input, .sheet-filters select { min-width: 0; }
  .auth-card { padding: 28px 22px 24px; }

  /* Modals become bottom sheets */
  .modal-scrim { align-items: flex-end; padding: 0; }
  .sheet {
    width: 100%; max-width: none; border-radius: 16px 16px 0 0;
    border-left: none; border-right: none; border-bottom: none;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    animation: sheetup .28s var(--ease);
  }
  .sheet-handle { display: block; width: 36px; height: 4px; border-radius: 3px; background: var(--border-strong); margin: -6px auto 14px; }
}

/* ===========================================================================
   Project share — public read-only view + owner dialog
   =========================================================================== */
/* Share view has no sidebar, so the shell collapses to a single column. */
.app.share-app { grid-template-columns: 1fr; }

.share-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 7px;
}
.share-badge svg { color: var(--text-3); }

/* Read-only card detail: title is a static heading, status pill is inert. */
.detail-title.ro { white-space: pre-wrap; }
.meta-pill.static { cursor: default; }
.meta-pill.static:hover { background: var(--surface-2); border-color: var(--border); }

/* Owner share dialog */
.btn.icon { padding: 7px; }
.share-intro { font-size: 13px; color: var(--text-3); line-height: 1.55; margin: 0 0 16px; }
.share-list { display: flex; flex-direction: column; gap: 8px; }
.share-empty { font-size: 12.5px; color: var(--text-4); padding: 6px 2px; }
.share-row { display: flex; align-items: center; gap: 8px; }
.share-url {
  flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border-2);
  color: var(--text-2); border-radius: 7px; padding: 8px 10px;
  font-size: 12px; font-family: var(--mono); outline: none;
}
.share-url:focus { border-color: var(--accent-line); }
.share-divider { height: 1px; background: var(--border); margin: 18px 0 16px; }
.share-create { text-align: left; }
.share-create-foot { display: flex; justify-content: flex-end; margin-top: 4px; }
