:root {
    --ink:        #17242c;
    --ink-soft:   #3a4a54;
    --muted:      #74858f;
    --rule:       #d3dbdf;
    --ground:     #e6ebed;
    --surface:    #ffffff;
    --accent:     #0e6e8a;
    --accent-dim: #cfe2e8;
    --warn:       #a8402a;
    --ok:         #2f6b4a;

    --sans: "IBM Plex Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

button {
    font: inherit;
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------------- structura ---------------- */

.shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px 64px;
}

.topbar {
    background: var(--ink);
    color: #eef3f5;
    padding: 14px 0;
    margin-bottom: 28px;
}

.topbar .inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 10px 16px;
    flex-wrap: wrap;
}

.topbar h1 {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}

.topbar h1 small {
    font-size: 13px;
    font-weight: 400;
    color: #9db3bd;
    margin-left: 8px;
}

.topbar .spacer { flex: 1; }

.topbar .meta {
    font-size: 13px;
    color: #9db3bd;
}

.topbar button,
.topbar .navlink,
.topbar summary {
    background: none;
    border: 1px solid #3c5462;
    color: #cfdde3;
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 13px;
    line-height: 1.5;
    text-decoration: none;
    white-space: nowrap;
}

.topbar button:hover,
.topbar .navlink:hover,
.topbar summary:hover { border-color: #6d8b99; color: #fff; }

.topbar :focus-visible { outline-color: #8fd0e2; }

/* ---------------- ritmul zilei ---------------- */

.rhythm {
    background: var(--surface);
    border: 1px solid var(--rule);
    padding: 20px 22px 14px;
    margin-bottom: 22px;
}

.rhythm-head {
    display: flex;
    align-items: baseline;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.rhythm-head .figure {
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.rhythm-head .figure b {
    font-family: var(--mono);
    font-size: 30px;
    font-weight: 500;
    letter-spacing: -0.03em;
    line-height: 1;
}

.rhythm-head .figure span {
    font-size: 13px;
    font-weight: 400;
    color: var(--muted);
}

.bars {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
    align-items: end;
    height: 74px;
}

.bars div {
    background: var(--accent-dim);
    min-height: 2px;
    border-radius: 1px 1px 0 0;
    transition: background .15s;
}

.bars div.busy { background: var(--accent); }
.bars div:hover { background: var(--ink); }

.hours {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 3px;
    margin-top: 6px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--muted);
    text-align: center;
}

.hours span:nth-child(odd) { visibility: hidden; }

/* ---------------- filtre ---------------- */

.filters {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--rule);
    padding: 16px 20px;
    margin-bottom: 22px;
}

.field { display: flex; flex-direction: column; gap: 5px; }

.field label {
    font-size: 12px;
    color: var(--muted);
}

.field input,
.field select {
    font: inherit;
    font-size: 14px;
    padding: 6px 8px;
    border: 1px solid var(--rule);
    border-radius: 3px;
    background: #fff;
    color: var(--ink);
    min-width: 150px;
}

.field input:focus,
.field select:focus { border-color: var(--accent); outline: none; }

.field label.check {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    color: var(--ink);
    padding: 6px 0;
    white-space: nowrap;
}

.field label.check input { width: auto; min-width: 0; margin: 0; }

.btn {
    border: 1px solid var(--ink);
    background: var(--ink);
    color: #fff;
    padding: 7px 16px;
    border-radius: 3px;
    font-size: 14px;
}

.btn:hover { background: var(--ink-soft); }

.btn.ghost {
    background: none;
    color: var(--ink);
    border-color: var(--rule);
}

.btn.ghost:hover { border-color: var(--ink); background: none; }

/* ---------------- taburi ---------------- */

.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 0;
}

.tabs button {
    background: none;
    border: 1px solid transparent;
    border-bottom: none;
    padding: 9px 18px;
    color: var(--muted);
    font-size: 14px;
    border-radius: 3px 3px 0 0;
    margin-bottom: -1px;
}

.tabs button[aria-selected="true"] {
    background: var(--surface);
    border-color: var(--rule);
    color: var(--ink);
    font-weight: 500;
}

/* ---------------- tabele ---------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-top: none;
    padding: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead th {
    text-align: left;
    font-weight: 500;
    font-size: 12px;
    color: var(--muted);
    padding: 11px 16px;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}

tbody td {
    padding: 9px 16px;
    border-bottom: 1px solid #eef2f4;
    vertical-align: baseline;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f6f9fa; }

td.t, td.id, td.num { font-family: var(--mono); font-size: 13px; }
td.id { color: var(--muted); }
td.name { font-weight: 500; }

.tag {
    display: inline-block;
    font-size: 12px;
    padding: 1px 7px;
    border: 1px solid var(--rule);
    border-radius: 2px;
    color: var(--ink-soft);
}

.tag.deny { border-color: #e2bcb2; background: #fbf1ef; color: var(--warn); }

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}

.pager {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-top: 1px solid var(--rule);
    font-size: 13px;
    color: var(--muted);
}

.pager .spacer { flex: 1; }

.pager button {
    background: none;
    border: 1px solid var(--rule);
    border-radius: 3px;
    padding: 4px 12px;
    color: var(--ink);
}

.pager button:disabled { opacity: .4; cursor: default; }

/* ---------------- login ---------------- */

.login {
    max-width: 380px;
    margin: 11vh auto 0;
    background: var(--surface);
    border: 1px solid var(--rule);
    padding: 32px;
}

.login h2 {
    margin: 0 0 6px;
    font-size: 19px;
    font-weight: 600;
}

.login p {
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 14px;
}

.login label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
}

.login input {
    width: 100%;
    font: inherit;
    padding: 9px 10px;
    border: 1px solid var(--rule);
    border-radius: 3px;
    margin-bottom: 14px;
}

.login input:focus { border-color: var(--accent); outline: none; }

.login-lang {
    display: flex;
    justify-content: flex-end;
    padding: 16px 20px 0;
}

.login .btn { width: 100%; }

.error {
    color: var(--warn);
    font-size: 13px;
    margin: 0 0 14px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 10px 18px;
    border-radius: 3px;
    font-size: 14px;
    box-shadow: 0 6px 20px rgba(23, 36, 44, .25);
}

/* ---------------- selectorul de limba ---------------- */

.lang {
    display: inline-flex;
    border: 1px solid #3c5462;
    border-radius: 3px;
    overflow: hidden;
}

.lang button,
.topbar .lang button {
    border: none;
    border-radius: 0;
    background: none;
    color: #9db3bd;
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .04em;
    line-height: 1.6;
}

.lang button + button { border-left: 1px solid #3c5462; }
.lang button:hover { color: #fff; }

.lang button[aria-pressed="true"] {
    background: #eef3f5;
    color: var(--ink);
}

/* pe ecranul de autentificare selectorul sta pe fond deschis */
.login-lang .lang,
.login-lang .lang button + button { border-color: var(--rule); }
.login-lang .lang { background: var(--surface); }
.login-lang .lang button { color: var(--muted); }
.login-lang .lang button:hover { color: var(--ink); }
.login-lang .lang button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* ---------------- meniul utilizatorului ---------------- */

.menu { position: relative; }

.menu summary {
    cursor: pointer;
    list-style: none;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; color: #6d8b99; }

.menu-items {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 20;
    min-width: 190px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 3px;
    box-shadow: 0 8px 24px rgba(23, 36, 44, .18);
    padding: 4px;
}

.topbar .menu-items button {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    color: var(--ink);
    font-size: 14px;
    padding: 7px 10px;
}

.topbar .menu-items button:hover { background: #f1f5f6; color: var(--ink); }

/* ---------------- formulare, dialoguri ---------------- */

.muted { color: var(--muted); }
.warn  { color: var(--warn); }

.form .field { margin-bottom: 14px; }
.form .field input,
.form .field select { width: 100%; }

.form small,
.form .hint {
    display: block;
    font-size: 12px;
    color: var(--muted);
}

.form .hint { margin: -8px 0 16px; }

label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--ink);
    cursor: pointer;
}

label.check input { width: auto; min-width: 0; margin: 0; flex: none; }
label.check.strong { font-weight: 500; font-size: 15px; }

.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1; min-width: 0; font-family: var(--mono); }

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.actions.left { justify-content: flex-start; flex-wrap: wrap; }

.btn:disabled { opacity: .5; cursor: default; }
.btn.danger { background: var(--warn); border-color: var(--warn); }
.btn.danger:hover { background: #8d3421; }

button.link {
    background: none;
    border: none;
    padding: 2px 4px;
    color: var(--accent);
    font-size: 14px;
}

button.link:hover { text-decoration: underline; }
button.link.danger { color: var(--warn); }

.dialog {
    width: min(440px, calc(100vw - 32px));
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 26px 28px;
    color: var(--ink);
    box-shadow: 0 18px 50px rgba(23, 36, 44, .3);
}

.dialog::backdrop { background: rgba(23, 36, 44, .45); }

.dialog h2 {
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.dialog p { margin: 0 0 14px; font-size: 14px; color: var(--ink-soft); }
.dialog p.error, .form p.error, .login p.error { color: var(--warn); }
.error:empty { display: none; }

/* ---------------- administrare ---------------- */

.panel.alone { border-top: 1px solid var(--rule); }
.scroll { overflow-x: auto; }

.panel-head {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--rule);
}

.panel-head p {
    margin: 0;
    flex: 1;
    font-size: 14px;
    color: var(--ink-soft);
    max-width: 68ch;
}

.panel-head .btn { white-space: nowrap; margin-left: auto; }

tr.off td { color: var(--muted); }
td.row-actions { text-align: right; white-space: nowrap; }

.status { white-space: nowrap; }

.status::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--rule);
    margin-right: 7px;
    vertical-align: 1px;
}

.status.on::before { background: var(--ok); }

.settings {
    padding: 24px 24px 20px;
    max-width: 720px;
}

.settings > label.check { margin-bottom: 20px; }
.settings .row { display: flex; gap: 14px; flex-wrap: wrap; }
.settings .row .grow { flex: 1; min-width: 220px; }

.settings fieldset {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 8px 0 20px;
    padding: 18px 0 0;
}

.settings legend {
    padding: 0 10px 0 0;
    font-weight: 500;
    font-size: 15px;
}

.settings fieldset .hint { margin: 0 0 14px; }
.settings .field.narrow input { min-width: 0; width: 96px; }

.notice {
    margin: 0 0 12px;
    padding: 9px 12px;
    border: 1px solid #e2bcb2;
    background: #fbf1ef;
    color: var(--warn);
    font-size: 13px;
    border-radius: 3px;
}

.day {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 44px;
    border-bottom: 1px solid #eef2f4;
}

.day:last-child { border-bottom: none; }
.day label.check { width: 150px; flex: none; }
.day .hours-range { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

.day input[type="time"] {
    font: inherit;
    font-family: var(--mono);
    font-size: 13px;
    padding: 5px 7px;
    border: 1px solid var(--rule);
    border-radius: 3px;
    color: var(--ink);
    background: #fff;
}

.day .closed-note { display: none; font-size: 13px; color: var(--muted); }
.day.closed .hours-range { display: none; }
.day.closed .closed-note { display: inline; }

.settings .note {
    margin: 14px 0 0;
    font-size: 13px;
    color: var(--muted);
    max-width: 68ch;
}

@media (max-width: 720px) {
    .topbar h1 small { display: none; }
    .topbar .meta { order: 9; width: 100%; }
    .panel-head { flex-direction: column; align-items: flex-start; gap: 12px; }
    .panel-head .btn { margin-left: 0; }
    .settings { padding: 18px 16px; }
    .day { flex-wrap: wrap; gap: 4px 14px; padding: 8px 0; }
    .day label.check { width: 100%; }
}

@media (max-width: 720px) {
    .bars, .hours { gap: 1px; }
    .bars { height: 56px; }
    .hours { font-size: 9px; }
    .hours span:nth-child(3n+1) { visibility: visible; }
    .hours span:not(:nth-child(3n+1)) { visibility: hidden; }
    .field input, .field select { min-width: 130px; }
    table.log thead th:nth-child(n+5), table.log tbody td:nth-child(n+5) { display: none; }
}

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