/* ============================================================
   Time Tracker — instrument-panel UI
   Palette
     ink       #1b2530   graphite base (topbar, text)
     surface   #f5f6f4   app background
     card      #ffffff
     go        #2e7d5b   active / recording green
     go-tint   #e8f2ec
     stop      #c2503a   stop / danger clay
     muted     #6b7683
     line      #e2e5e2   hairlines
   Type: system sans for UI, monospace for all numerics (tabular time reads).
   ============================================================ */

:root {
    --ink: #1b2530;
    --surface: #f5f6f4;
    --card: #ffffff;
    --go: #2e7d5b;
    --go-tint: #e8f2ec;
    --go-dark: #24634780;
    --stop: #c2503a;
    --muted: #6b7683;
    --line: #e2e5e2;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(27, 37, 48, .05), 0 4px 16px rgba(27, 37, 48, .04);
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--ink);
    background: var(--surface);
    line-height: 1.5;
    font-size: 15px;
}

a { color: var(--go); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    height: 58px;
    background: var(--ink);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 650;
    letter-spacing: .01em;
    font-size: 16px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--go);
    position: relative;
    flex: 0 0 auto;
}
.brand-mark::after {
    content: ""; position: absolute; inset: 3px;
    border-radius: 50%; background: var(--go);
}
.mainnav { display: flex; gap: 4px; margin-left: 8px; }
.mainnav a {
    color: #b8c2cc;
    padding: 8px 12px;
    border-radius: 7px;
    font-weight: 500;
    font-size: 14px;
}
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.07); text-decoration: none; }
.mainnav a.is-active { color: #fff; background: rgba(255,255,255,.12); }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.user-name { font-size: 13.5px; color: #cdd5dd; }
.tag {
    font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
    background: var(--go); color: #fff; padding: 2px 6px; border-radius: 5px; vertical-align: 1px;
}
.btn-link {
    background: none; border: none; cursor: pointer;
    color: var(--go); font: inherit; padding: 0; font-size: 14px;
}
.topbar .btn-link { color: #cdd5dd; }
.topbar .btn-link:hover { color: #fff; text-decoration: underline; }

/* ---------- Layout ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 28px 24px 40px; }
.lead { color: var(--muted); margin: 0 0 20px; max-width: 70ch; }

.pagefoot {
    text-align: center; color: var(--muted); font-size: 12.5px;
    padding: 24px; border-top: 1px solid var(--line);
}

/* ---------- Flash / notices ---------- */
.flash {
    background: var(--go-tint); color: #1f5c41;
    border: 1px solid #cfe4d8; border-radius: 8px;
    padding: 10px 14px; margin-bottom: 18px; font-size: 14px;
}
.notice { border-radius: 8px; padding: 12px 14px; font-size: 14px; margin: 14px 0; }
.notice-warn { background: #fdf1ee; border: 1px solid #f2cdc4; color: #8f3a29; }
.notice-ok   { background: var(--go-tint); border: 1px solid #cfe4d8; color: #1f5c41; }
.notice code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }

/* ---------- Timer panel (the signature) ---------- */
.timer-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 28px;
    margin-bottom: 24px;
    transition: border-color .2s, background .2s;
}
.timer-panel.is-running {
    border-left-color: var(--go);
    background: linear-gradient(0deg, var(--card), var(--card)), var(--go-tint);
    background-blend-mode: normal;
}
.timer-face {
    display: flex; align-items: center; justify-content: space-between;
    gap: 20px; flex-wrap: wrap;
}
.timer-context { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.timer-client { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.timer-task { font-size: 20px; font-weight: 600; }
.timer-desc { font-size: 14px; color: var(--muted); }
.timer-context .muted { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.timer-context .timer-client.muted { font-size: 13px; }
.timer-context .timer-task.muted { font-size: 18px; }

.timer-clock {
    font-family: var(--mono);
    font-size: 46px;
    font-weight: 500;
    letter-spacing: .01em;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    line-height: 1;
    position: relative;
    padding-left: 26px;
}
.is-running .timer-clock { color: var(--go); }
.is-running .timer-clock::before {
    content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 12px; height: 12px; border-radius: 50%; background: var(--stop);
    animation: rec 1.4s ease-in-out infinite;
}
@keyframes rec { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.timer-controls {
    display: flex; gap: 10px; margin-top: 22px; align-items: stretch;
}
.task-select { flex: 0 0 auto; min-width: 220px; }
.desc-input { flex: 1 1 auto; }
.timer-controls[hidden] { display: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 9px 18px; border-radius: 8px; border: 1px solid var(--line);
    background: #fff; color: var(--ink); font: inherit; font-weight: 550; font-size: 14px;
    cursor: pointer; transition: background .12s, border-color .12s, transform .04s;
}
.btn:hover { background: #f4f5f3; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #29343f; }
.btn-block { width: 100%; padding: 11px; }
.btn-start {
    background: var(--go); border-color: var(--go); color: #fff;
    padding-left: 30px; padding-right: 30px; font-size: 15px;
}
.btn-start:hover { background: #276a4d; }
.btn-stop {
    background: var(--stop); border-color: var(--stop); color: #fff;
    padding-left: 40px; padding-right: 40px; font-size: 15px;
}
.btn-stop:hover { background: #a8412f; }
.btn:disabled { opacity: .6; cursor: default; }

/* ---------- Cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px 24px; margin-bottom: 22px;
}
.card-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; margin-bottom: 14px;
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.card-foot { margin: 14px 0 0; font-size: 14px; }
.empty { color: var(--muted); padding: 8px 0 4px; }
.today-total { color: var(--muted); font-size: 14px; }
.today-total strong { font-family: var(--mono); color: var(--ink); font-weight: 600; }

/* ---------- Tables ---------- */
.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td {
    text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.grid thead th {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); font-weight: 600; border-bottom: 1.5px solid var(--line);
}
.grid tbody tr:last-child td { border-bottom: none; }
.grid .num { text-align: right; }
.grid .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
tr.is-archived { opacity: .5; }
.row-actions { display: flex; gap: 12px; justify-content: flex-end; }
.inline { display: inline; }
.danger { color: var(--stop); }

/* ---------- Forms ---------- */
input[type=text], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=number], select {
    font: inherit; font-size: 14px; color: var(--ink);
    padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; width: 100%; min-width: 0;
}
input:focus, select:focus, .btn:focus-visible, a:focus-visible {
    outline: 2px solid var(--go); outline-offset: 1px; border-color: var(--go);
}
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7683' stroke-width='1.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 30px; }
label { font-weight: 500; }

.shake { animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

/* stacked auth/login forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--muted); }
.stack input { color: var(--ink); }

/* inline "row" forms (admin add/edit) */
.rowform {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    margin-bottom: 12px;
}
.rowform.tight { margin: 0; }
.rowform.subtle { margin-top: 6px; }
.rowform.subtle input { max-width: 240px; }
.rowform input[type=text], .rowform input[type=email] { flex: 1 1 160px; }
.rowform input[type=number] { flex: 0 0 130px; }
.rowform input[type=password] { flex: 0 0 200px; }
.rowform select { flex: 0 0 auto; width: auto; min-width: 150px; }
.status { font-size: 12px; padding: 2px 8px; border-radius: 20px; }
.status.ok { background: var(--go-tint); color: #1f5c41; }
.status.off { background: #eee; color: var(--muted); }

/* entry add form */
.entry-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.entry-form .field { display: flex; flex-direction: column; gap: 5px; }
.entry-form .field label { font-size: 12.5px; color: var(--muted); }
.entry-form .field.grow { flex: 1 1 200px; }

/* ---------- Filters (reports) ---------- */
.filters {
    display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.filters .field { display: flex; flex-direction: column; gap: 5px; }
.filters .field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filters select, .filters input { width: auto; min-width: 140px; }
.report-actions { display: flex; gap: 10px; margin-bottom: 18px; }

/* ---------- Report sheet ---------- */
.report-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 20px; padding-bottom: 16px; margin-bottom: 4px; border-bottom: 2px solid var(--ink);
    flex-wrap: wrap;
}
.report-header h2 { margin: 0 0 2px; font-size: 20px; }
.report-total { text-align: right; display: flex; flex-direction: column; gap: 1px; }
.report-total-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.report-total-hours { font-family: var(--mono); font-size: 26px; font-weight: 600; }
.report-total-amount { font-family: var(--mono); font-size: 16px; color: var(--go); font-weight: 600; }
.report-grid tfoot th { border-top: 2px solid var(--line); border-bottom: none; font-size: 13px; padding-top: 12px; }
.report-grid tfoot .mono { font-weight: 700; }

/* ---------- Auth pages ---------- */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 24px; background: var(--ink);
}
.auth-card {
    background: var(--card); border-radius: 14px; padding: 34px 32px;
    width: 100%; max-width: 380px; box-shadow: 0 12px 40px rgba(0,0,0,.28);
}
.auth-title { margin: 0 0 4px; font-size: 22px; }
.auth-sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .topbar { gap: 10px; padding: 0 14px; }
    .user-name { display: none; }
    .mainnav { margin-left: 0; }
    .mainnav a { padding: 8px 9px; }
    .wrap { padding: 20px 14px 32px; }
    .timer-clock { font-size: 38px; }
    .timer-controls { flex-wrap: wrap; }
    .task-select, .desc-input { flex: 1 1 100%; min-width: 0; }
    .grid { font-size: 13px; }
    .grid th, .grid td { padding: 8px 8px; }
}

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

/* ---------- Print (reports → invoice/PDF) ---------- */
@media print {
    .topbar, .pagefoot, .no-print, .filters, .report-actions, .card-foot { display: none !important; }
    body { background: #fff; font-size: 12px; }
    .wrap { max-width: none; padding: 0; }
    .card { box-shadow: none; border: none; padding: 0; margin: 0 0 18px; }
    .report-sheet { border: none; }
    .grid th, .grid td { padding: 6px 8px; }
    a { color: var(--ink); }
}
