:root {
    /* Kawarem brand: vertical gradient from green-teal (top) to blue (bottom) */
    --brand-green: #2dc2a4;
    --brand-mid: #299caf;
    --brand-blue: #2570bc;
    --brand-gradient: linear-gradient(180deg, var(--brand-green), var(--brand-blue));
    --brand-gradient-x: linear-gradient(135deg, var(--brand-green), var(--brand-blue));
    --ink: #1d1d1d;
    --muted: #6b7378;
    --line: #e3e6e6;
    --bg: #efefef;
    --card: #ffffff;
    --brand: var(--brand-mid);
    --brand-2: var(--brand-green);
    --brand-dark: var(--brand-blue);
    --night: #1d1d1d;
    --font-body: "Almarai", system-ui, sans-serif;
    --font-head: "Cairo", "Almarai", system-ui, sans-serif;
    --ok: #0f9d6b;
    --ok-bg: #e7f7f0;
    --warn: #b7791f;
    --warn-bg: #fdf4e3;
    --bad: #d13b3b;
    --bad-bg: #fdecec;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    font-size: 15px;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
    background: var(--brand-gradient-x);
    color: #fff;
    box-shadow: 0 2px 12px rgba(37, 112, 188, .25);
}
.topbar-inner {
    max-width: 1180px; margin: 0 auto; padding: 12px 20px;
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 15px; color: #fff; display: flex; align-items: center; gap: 10px; }
.brand:hover { text-decoration: none; }
.brand img { height: 28px; display: block; }
.brand span { padding-inline-start: 10px; border-inline-start: 1px solid rgba(255,255,255,.4); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: rgba(255,255,255,.85); padding: 6px 12px; border-radius: 8px; font-size: 14px; }
.nav a:hover { color: #fff; background: rgba(255,255,255,.14); text-decoration: none; }
.nav a.active { color: var(--brand-blue); background: #fff; font-weight: 700; }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #fff; }
.who form { margin: 0; }
.link-btn { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; padding: 4px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; }
.link-btn:hover { background: rgba(255,255,255,.1); }

.container { max-width: 1180px; margin: 0 auto; padding: 24px 20px 60px; }
.narrow { max-width: 720px; }

h1, h2, .brand, .btn, .stat .value, .timer, th { font-family: var(--font-head); }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 12px; }
/* Brand wave divider: one whole image, never tiled. */
.wave { display: block; width: min(100%, 420px); aspect-ratio: 1540 / 38; margin: 18px auto 20px; border: 0;
    background: url('../images/divider.png') no-repeat center / 100% 100%; opacity: .6; }
.sub { color: var(--muted); margin: 0 0 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.accent { border-color: transparent; background: var(--brand-gradient); color: #fff; }
.stat.accent .label { color: rgba(255,255,255,.8); }

/* Forms */
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 4px; }
input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=month], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 9px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(41, 156, 175, .3); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: 18px; height: 18px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1; min-width: 160px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 150px; }
.inline { display: inline; margin: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 18px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 600;
    cursor: pointer; background: var(--brand-gradient-x); color: #fff; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(.94); text-decoration: none; }
.btn-light { background: #fff; color: var(--ink); border-color: #cfd5d6; }
.btn-light:hover { background: #f1f5f9; }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #a92e2e; }
.btn-ok { background: var(--brand-gradient-x); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 17px; border-radius: 12px; }
.btn-block { width: 100%; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: #f6f8f8; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td:not(.note) { white-space: nowrap; }
td.num, th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.note { max-width: 320px; white-space: pre-wrap; color: #334155; }
tfoot td { font-weight: 700; background: #f6f8f8; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: #e3f5f2; color: #1f8f7a; }
.badge-muted { background: #f1f5f9; color: var(--muted); }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; border: 1px solid; }
.alert-ok { background: var(--ok-bg); border-color: #b9e8d4; color: #0b6b49; }
.alert-bad { background: var(--bad-bg); border-color: #f5c2c2; color: #9b2c2c; }
.alert-warn { background: var(--warn-bg); border-color: #f3dcae; color: #8a5a12; }
.alert ul { margin: 0; padding-inline-start: 18px; }

.code-box {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 28px; letter-spacing: 6px;
    direction: ltr; text-align: center; background: var(--night); color: var(--brand-2);
    padding: 14px; border-radius: 10px; margin: 10px 0; user-select: all;
}

/* Clock screen */
.clock-card { text-align: center; padding: 32px 20px; }
.clock-state { color: var(--muted); margin-bottom: 4px; }
.timer { font-size: 54px; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; letter-spacing: 2px; margin: 4px 0 8px; }
.timer.running { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.clock-project { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.clock-form { max-width: 420px; margin: 0 auto; text-align: right; }
.divider { border: none; border-top: 1px dashed var(--line); margin: 24px 0; }
details summary { cursor: pointer; color: var(--brand-dark); font-weight: 600; }
details[open] summary { margin-bottom: 12px; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: var(--brand-blue) url('../images/pattern.jpg') center / cover no-repeat;
}
.login-logo { display: block; width: 200px; max-width: 70%; margin: 0 auto 18px; }
.login-card { width: 100%; max-width: 390px; background: #fff; border-radius: 18px; padding: 34px 28px; box-shadow: 0 24px 60px rgba(20, 60, 100, .35); }
.login-card h1 { text-align: center; }
.login-card .sub { text-align: center; }
.code-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 24px !important; letter-spacing: 6px; text-align: center; text-transform: uppercase; direction: ltr; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.ltr { direction: ltr; unicode-bidi: embed; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.diff { font-size: 13px; }
.diff del { color: var(--bad); }
.diff ins { color: var(--ok); text-decoration: none; }

@media (max-width: 640px) {
    .topbar-inner { gap: 10px; }
    .nav { order: 3; width: 100%; }
    .timer { font-size: 42px; }
    .container { padding: 18px 14px 40px; }
}

@media print {
    .topbar, .no-print { display: none !important; }
    body { background: #fff; }
    .card { border: none; padding: 0; }
    .container { padding: 0; max-width: none; }
}


/* ---------- Hours board ---------- */
.toolbar { display: flex; flex-direction: column; gap: 14px; }
.toolbar-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.toolbar .filters { justify-content: flex-start; }
.period-label { font-family: var(--font-head); font-weight: 700; font-size: 17px; }
.icon-btn { width: 36px; height: 36px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
    border: 1px solid #cfd5d6; background: #fff; color: var(--ink); font-size: 22px; line-height: 1; }
.icon-btn:hover { background: #f1f5f5; text-decoration: none; border-color: var(--brand); color: var(--brand-dark); }

/* Month pages */
.month-pager { display: flex; align-items: center; gap: 10px; }
.pager-year { font-family: var(--font-head); font-weight: 800; font-size: 18px; color: var(--brand-dark); }
.month-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; flex: 1; padding: 2px; }
.month-pages a { position: relative; flex: none; padding: 7px 13px; border-radius: 9px; color: var(--muted); font-family: var(--font-head); font-weight: 700; font-size: 14px; white-space: nowrap; }
.month-pages a:hover { background: #f1f5f5; color: var(--ink); text-decoration: none; }
.month-pages a.busy::after { content: ''; position: absolute; bottom: 3px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--brand-green); }
.month-pages a.current { color: var(--ink); box-shadow: inset 0 0 0 1px #cfd5d6; }
.month-pages a.active { background: var(--brand-gradient-x); color: #fff; box-shadow: 0 2px 8px rgba(37, 112, 188, .3); }
.month-pages a.active::after { background: #fff; }

.review-link { align-self: center; font-size: 14px; color: var(--warn); }
.period-stats { margin-bottom: 18px; }
.tiny { font-size: 11px; }

/* A week is a tinted panel; consecutive weeks alternate between the two brand tints. */
.week { --tint: rgba(45, 194, 164, .09); --edge: rgba(45, 194, 164, .45); --ink-tint: #1f8f7a;
    background: var(--tint); border: 1px solid var(--edge); border-radius: 16px; padding: 12px; margin-bottom: 18px; }
.week-alt { --tint: rgba(37, 112, 188, .07); --edge: rgba(37, 112, 188, .35); --ink-tint: var(--brand-blue); }
.week-review { --tint: transparent; --edge: transparent; padding: 0; border: 0; }
.week-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px 6px 12px; }
.week-title { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 800; font-size: 16px; color: var(--ink-tint); }
.week-no { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-gradient); color: #fff; font-size: 15px; }
.week-range { font-family: var(--font-body); font-weight: 400; font-size: 13px; color: var(--muted); }
.week-totals { display: flex; gap: 6px; flex-wrap: wrap; }
.week-totals span { padding: 3px 11px; border-radius: 999px; background: #fff; border: 1px solid var(--edge); font-size: 13px; font-weight: 700; color: var(--ink-tint); font-variant-numeric: tabular-nums; }
.week-totals .week-money { background: var(--ink-tint); border-color: transparent; color: #fff; }
.week-days { display: flex; flex-direction: column; gap: 10px; }

.day-group { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    overflow: hidden; transition: box-shadow .2s, transform .2s, border-color .2s; }
.day-group::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--brand-gradient); transition: width .2s; }
.day-group:hover { box-shadow: 0 6px 22px rgba(37, 112, 188, .12); border-color: rgba(41, 156, 175, .45); }
.day-group:hover::before { width: 6px; }
.day-group.is-today { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(45, 194, 164, .15); }

.day-head { display: flex; align-items: center; gap: 16px; padding: 10px 18px 10px 14px; padding-inline-start: 20px; background: #f6f8f8; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.day-title { display: flex; align-items: center; gap: 8px; color: var(--ink); min-width: 190px; }
.day-num { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: #fff; border: 1px solid var(--line); font-family: var(--font-head); font-weight: 800; font-size: 16px; color: var(--brand-dark); }
.is-today .day-num { background: var(--brand-gradient); color: #fff; border-color: transparent; }
.day-name { font-family: var(--font-head); font-weight: 800; font-size: 16px; }
.day-date { color: var(--muted); font-size: 13px; }
.day-totals { display: flex; gap: 6px; margin-inline-start: auto; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip-money { background: var(--brand-gradient-x); color: #fff; border-color: transparent; }
.chip-add { color: var(--brand-dark); padding: 2px 9px; }
.chip-add:hover { text-decoration: none; background: var(--brand-gradient-x); color: #fff; }

/* 24-hour strip: 00:00 at the start (right in RTL) */
.timeline { position: relative; flex: 1; min-width: 160px; max-width: 420px; height: 10px; border-radius: 999px; background: #e6eaea; }
.timeline .tick { position: absolute; top: -2px; bottom: -2px; width: 1px; background: #c9d0d0; }
.timeline .seg { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: var(--brand-gradient-x); transition: transform .15s, box-shadow .15s; }
.timeline .seg.open { background: repeating-linear-gradient(45deg, var(--brand-green), var(--brand-green) 4px, var(--brand-mid) 4px, var(--brand-mid) 8px); }
.timeline .seg.warn { background: #e0a43a; }
.timeline .seg.hl { transform: scaleY(1.7); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--brand-blue); z-index: 1; }

.day-table th { background: transparent; font-size: 12px; padding-top: 8px; padding-bottom: 6px; }
.day-table td { padding-top: 9px; padding-bottom: 9px; }
.day-table tbody tr { transition: background .15s; }
.day-table tbody tr:hover, .day-table tbody tr.hl { background: #f2faf8; }
.day-table tr.needs-review { background: #fffaf0; }
.day-table tr.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: rgba(45, 194, 164, .35); } 100% { background: transparent; } }
.who-name { font-weight: 700; }
.day-table th, .day-table td { padding-inline: 10px; }
.day-table td.note { min-width: 120px; max-width: 320px; white-space: normal; }
.note-text { white-space: pre-wrap; }
.tags { margin-top: 3px; display: flex; gap: 4px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.icon-act { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
    border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.icon-act svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.icon-act:hover { background: #eef4f4; color: var(--brand-dark); text-decoration: none; }
.icon-act.bad:hover { background: var(--bad-bg); color: var(--bad); }
.icon-act.ok { color: var(--ok); }
.icon-act.ok:hover { background: var(--ok-bg); }
.btn-quiet-danger:hover { color: var(--bad); border-color: #f0b8b8; background: var(--bad-bg); }

.editable { cursor: text; position: relative; border-radius: 6px; }
.editable:hover { background: rgba(41, 156, 175, .1); box-shadow: inset 0 0 0 1px rgba(41, 156, 175, .45); }
.editable.editing { padding: 4px 6px; }
.cell-input { width: 72px !important; padding: 5px 6px !important; text-align: center; direction: ltr; font-family: var(--font-head); font-weight: 700;
    border: 2px solid var(--brand) !important; border-radius: 7px !important; }
.editable.invalid .cell-input { border-color: var(--bad) !important; animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }

@media (max-width: 640px) {
    .week { padding: 8px; }
    .timeline { order: 3; max-width: none; flex-basis: 100%; }
    .day-totals { margin-inline-start: 0; }
}
.time-input { direction: ltr; text-align: center; font-family: var(--font-head); font-weight: 700; letter-spacing: 1px; }
.month-switch { display: flex; align-items: center; gap: 8px; }
.month-switch-label { font-family: var(--font-head); font-weight: 700; font-size: 16px; min-width: 130px; text-align: center; }
