/* SewLong Tasks */
:root {
    --navy: #1a2a3a;
    --navy-2: #24384d;
    --blue: #1c5fa8;
    --blue-dark: #164c87;
    --light: #6eb8f7;
    --bg: #eef2f6;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #616e7c;
    --line: #d9e2ec;
    --fm: #1c5fa8;
    --shop: #c47a1c;
    --it: #2f8f5b;
    --idea: #6eb8f7;
    --wait: #d4a72c;
    --danger: #c0392b;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 32, 48, .08), 0 2px 8px rgba(16, 32, 48, .06);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); min-height: 100vh; font-size: 15px; line-height: 1.45; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 17px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88em; background: #eef2f6; padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); font-size: 13px; }
[hidden] { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn {
    font: inherit; font-size: 14px; font-weight: 600;
    border: 1px solid var(--line); background: #fff; color: var(--text);
    padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: #b8c4d0; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-ghost { background: transparent; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { border-color: var(--danger); }
.btn.armed { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }

input[type=text], input[type=password], input[type=search], input[type=datetime-local], select, textarea {
    font: inherit; font-size: 15px; color: var(--text);
    width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--light); outline-offset: 0; border-color: var(--blue); }
textarea { resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 12px; }
label > input, label > select, label > textarea { margin-top: 5px; font-weight: 400; }
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.align-end { align-self: end; margin-bottom: 22px; }

/* ---------- top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 18px;
    background: var(--navy); color: #fff; padding: 10px 20px;
    border-bottom: 3px solid var(--light);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tab {
    font: inherit; font-size: 14px; font-weight: 600; color: #b9c8d8; background: transparent;
    border: 0; padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: #fff; background: var(--navy-2); }
.tab.active { color: #fff; background: var(--blue); }
.logout .btn { color: #b9c8d8; border-color: #3b5168; }
.logout .btn:hover { color: #fff; border-color: #fff; }

main { padding: 18px 20px 40px; max-width: 1600px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------- quick add ---------- */
.quick-add {
    display: grid; grid-template-columns: 1fr 190px auto; gap: 8px;
    background: var(--panel); padding: 10px; border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.quick-add input { font-size: 16px; }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: start; }
.column {
    background: #f8fafc; border-radius: var(--radius); box-shadow: var(--shadow);
    border-top: 4px solid var(--fm); padding: 12px; min-height: 160px;
}
.cat-shop { border-top-color: var(--shop); }
.cat-it { border-top-color: var(--it); }
.cat-ideas { border-top-color: var(--idea); background: #f3f9ff; }
.column-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.column-head h2 { color: var(--navy); }
.count { font-size: 12px; font-weight: 700; color: var(--muted); background: #e4ebf2; border-radius: 999px; padding: 2px 9px; }

.task-list { display: flex; flex-direction: column; gap: 8px; min-height: 36px; border-radius: 8px; transition: background .15s; }
.task-list.drag-over { background: #e3effc; outline: 2px dashed var(--light); outline-offset: 2px; }
.waiting-block { margin-top: 14px; }
.waiting-block h3 { margin-bottom: 6px; }
.empty { font-size: 13px; color: #9aa5b1; padding: 10px 4px; text-align: center; }

.task {
    display: flex; align-items: flex-start; gap: 10px;
    background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px;
    cursor: grab; transition: box-shadow .15s, transform .15s, opacity .2s;
}
.task:hover { box-shadow: var(--shadow); }
.task.dragging { opacity: .45; }
.task.leaving { opacity: 0; transform: translateX(16px); }
.task-list.waiting .task { background: #fffaeb; border-color: #f0dfa8; }
.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-weight: 600; word-wrap: break-word; }
.task-notes { font-size: 13px; color: var(--muted); margin-top: 3px; white-space: pre-wrap; word-wrap: break-word;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.task-meta { font-size: 11px; color: #9aa5b1; margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 1px 6px; border-radius: 4px; background: #e4ebf2; color: var(--navy); }
.badge.src-filemaker { background: #dbe8f7; color: var(--blue); }
.badge.src-claude { background: #f3e8dc; color: #a35a1c; }

.check {
    flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
    border: 2px solid #b8c4d0; background: #fff; cursor: pointer; padding: 0; position: relative;
}
.check:hover { border-color: var(--it); background: #e8f5ee; }
.check:hover::after, .check.checked::after {
    content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
    border: solid var(--it); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.check.checked { background: var(--it); border-color: var(--it); }
.check.checked::after { border-color: #fff; }
.icon-btn {
    flex: none; border: 0; background: transparent; cursor: pointer; color: #9aa5b1;
    width: 26px; height: 26px; border-radius: 6px; font-size: 14px; padding: 0;
}
.icon-btn:hover { background: #eef2f6; color: var(--navy); }
.icon-btn svg { display: block; margin: auto; }

/* ideas */
.idea-list { display: flex; flex-direction: column; gap: 8px; }
.idea {
    background: #fff; border: 1px solid #cfe4f8; border-left: 3px solid var(--idea);
    border-radius: 8px; padding: 10px; cursor: pointer;
}
.idea:hover { box-shadow: var(--shadow); }
.idea.promoted { opacity: .6; border-left-color: #9aa5b1; }
.idea-text { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.idea-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; }
.idea-actions { display: flex; gap: 2px; }
.star.on { color: #d4a72c; }
.show-promoted { margin-top: 10px; width: 100%; }

/* ---------- done ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h2 { margin-right: auto; font-size: 20px; color: var(--navy); }
.toolbar select, .toolbar input { width: auto; min-width: 160px; }
.done-day { margin-bottom: 18px; }
.done-day h3 { margin: 0 0 8px 2px; }
.done-item {
    display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line);
    border-left: 4px solid var(--fm); border-radius: 8px; padding: 10px 12px; margin-bottom: 6px;
}
.done-item.cat-shop { border-left-color: var(--shop); }
.done-item.cat-it { border-left-color: var(--it); }
.done-item .task-body { cursor: pointer; }
.done-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #dbe8f7; color: var(--fm); white-space: nowrap; }
.pill.cat-shop { background: #f7e9d6; color: var(--shop); }
.pill.cat-it { background: #dcf0e4; color: var(--it); }

/* ---------- panels ---------- */
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.panel h2 { margin-bottom: 6px; color: var(--navy); }
.report-grid { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
.btn-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.preview-panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; min-height: 640px; }
.preview-head { padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f8fafc; font-size: 14px; }
#rp-frame { flex: 1; width: 100%; min-height: 760px; border: 0; background: #eef2f6; }
.history { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.history h3 { margin-bottom: 8px; }
.history-item { font-size: 13px; padding: 6px 0; border-bottom: 1px solid #eef2f6; }
.history-item strong { color: var(--navy); }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.inline-form { display: flex; gap: 8px; margin: 12px 0; }
.stack-form { margin-top: 10px; }
.new-key { background: #e8f5ee; border: 1px solid #b6dfc7; border-radius: 8px; padding: 12px; margin-bottom: 12px; font-size: 14px; }
.key-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.key-row code { flex: 1; word-break: break-all; background: #fff; padding: 8px; font-size: 13px; }
.key-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #eef2f6; }
.key-item .grow { flex: 1; min-width: 0; }
.key-item.revoked { opacity: .5; }
.key-item .label { font-weight: 600; }
table.ref { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
table.ref td { padding: 6px 4px; border-bottom: 1px solid #eef2f6; vertical-align: top; }
table.ref td:last-child code { word-break: break-all; }

/* ---------- dialog ---------- */
.dialog {
    border: 0; border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 24px));
    box-shadow: 0 20px 60px rgba(16, 32, 48, .35); color: var(--text);
}
.dialog::backdrop { background: rgba(26, 42, 58, .55); }
.dialog form { padding: 20px; }
.dialog h2 { margin-bottom: 14px; color: var(--navy); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.meta { font-size: 12px; color: var(--muted); margin: 0 0 14px; }
.dialog-actions { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }

/* ---------- toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
    background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; pointer-events: none; transition: all .2s; z-index: 100;
    max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast.error { background: var(--danger); }
.toast button { margin-left: 12px; background: transparent; color: var(--light); border: 0; font: inherit; font-weight: 700; cursor: pointer; }

/* ---------- auth pages ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--navy) 0%, #20364d 55%, var(--blue) 140%); }
.auth-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-app { font-weight: 700; font-size: 18px; color: var(--navy); }
.auth-sub { font-size: 13px; color: var(--muted); }
.auth-form { margin-top: 8px; }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
.alert-error { background: #fdecea; color: #8e2b20; border: 1px solid #f5c2bc; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
    .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .report-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
    .brand { flex: 1; }
    .tabs { order: 3; flex-basis: 100%; }
    main { padding: 12px 10px 40px; }
    .board { grid-template-columns: 1fr; }
    .quick-add { grid-template-columns: 1fr auto; }
    .quick-add input { grid-column: 1 / -1; }
    .two-col { grid-template-columns: 1fr; }
    .toolbar select, .toolbar input { flex: 1; min-width: 0; }
    .done-item { flex-wrap: wrap; }
    .icon-btn { width: 32px; height: 32px; }
    .check { width: 26px; height: 26px; }
    .check:hover::after, .check.checked::after { left: 8px; top: 3px; }
}
