:root {
    --bg: #0b0c0e;
    --surface: #15171a;
    --surface-2: #1d2024;
    --line: rgba(255, 255, 255, 0.12);
    --text: #f4f5f6;
    --muted: #9da3ad;
    --accent: #ff7a1a;
    --accent-soft: rgba(255, 122, 26, 0.12);
    --green: #35d07f;
    --red: #ff5a4f;
    --yellow: #ffd15f;
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    color: var(--text);
    background:
        linear-gradient(180deg, rgba(255, 122, 26, 0.08), transparent 210px),
        var(--bg);
    font: 14px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.app-shell {
    width: min(100%, 430px);
    height: 100dvh;
    margin: 0 auto;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
    overflow: hidden;
}

.login-view,
.recorder-view,
.journal-view {
    height: 100%;
}

.login-view {
    display: grid;
    place-items: center;
}

.login-card {
    width: 100%;
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(21, 23, 26, 0.96);
    box-shadow: var(--shadow);
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2px;
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
}

h1,
p {
    margin: 0;
}

.brand-row h1,
.app-header h1 {
    color: var(--accent);
    font-size: 22px;
    line-height: 1;
    letter-spacing: 0;
}

.brand-row p,
.title-stack span,
.field-label span {
    color: var(--muted);
    font-size: 12px;
}

.field-label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.text-field,
.date-field,
.text-area {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    background: #101215;
    color: var(--text);
}

.text-field,
.date-field {
    height: 40px;
    padding: 0 10px;
}

.text-area {
    min-height: 82px;
    max-height: 112px;
    resize: none;
    padding: 10px;
}

.text-field:focus,
.date-field:focus,
.text-area:focus {
    border-color: rgba(255, 122, 26, 0.72);
}

.primary-btn,
.secondary-btn,
.journal-btn,
.icon-btn {
    min-height: 40px;
    border: 1px solid rgba(255, 122, 26, 0.68);
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 800;
}

.secondary-btn {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.journal-btn {
    width: 100%;
    height: 46px;
}

.icon-btn {
    width: 40px;
    padding: 0;
    font-size: 22px;
    display: grid;
    place-items: center;
}

.full {
    width: 100%;
}

.form-error {
    min-height: 18px;
    color: var(--red);
    font-size: 12px;
}

.recorder-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.app-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.header-actions {
    display: inline-flex;
    gap: 6px;
}

.title-stack {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.status-strip {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
}

.status-pill {
    height: 25px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.04);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
}

.status-pill.ok i {
    background: var(--green);
    box-shadow: 0 0 9px rgba(53, 208, 127, 0.65);
}

.status-pill.warn i {
    background: var(--yellow);
    box-shadow: 0 0 9px rgba(255, 209, 95, 0.65);
}

.status-pill.fail i {
    background: var(--red);
    box-shadow: 0 0 9px rgba(255, 90, 79, 0.65);
}

.dictaphone {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.date-line {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(21, 23, 26, 0.94);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.record-panel {
    flex: 1 1 auto;
    min-height: 230px;
    display: grid;
    grid-template-rows: 28px 116px auto auto auto;
    justify-items: center;
    align-content: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(21, 23, 26, 0.96);
    box-shadow: var(--shadow);
}

.record-btn {
    width: 112px;
    height: 112px;
    border: 1px solid rgba(255, 122, 26, 0.72);
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 900;
    font-size: 18px;
}

.record-panel strong {
    font-size: 18px;
}

.record-panel > span {
    max-width: 270px;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
}

.record-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.meter {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.meter span {
    width: 4px;
    height: 8px;
    border-radius: 4px;
    background: var(--accent);
    opacity: 0.5;
}

.meter.active span {
    animation: meter 0.7s infinite alternate;
}

.meter span:nth-child(2) { animation-delay: 0.08s; }
.meter span:nth-child(3) { animation-delay: 0.16s; }
.meter span:nth-child(4) { animation-delay: 0.24s; }
.meter span:nth-child(5) { animation-delay: 0.32s; }

@keyframes meter {
    from { transform: scaleY(0.55); }
    to { transform: scaleY(2.3); opacity: 1; }
}

.text-send {
    flex: 0 0 auto;
    display: grid;
    gap: 8px;
}

.journal-view {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.journal-tabs {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.journal-tab {
    flex: 0 0 auto;
    height: 34px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    font-weight: 800;
}

.journal-tab.active {
    color: var(--accent);
    border-color: rgba(255, 122, 26, 0.72);
    background: var(--accent-soft);
}

.journal-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: 8px;
    padding-bottom: 8px;
}

.journal-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(21, 23, 26, 0.96);
    overflow: hidden;
}

.journal-table th,
.journal-table td {
    padding: 7px 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(244, 245, 246, 0.86);
    font-size: 11px;
    line-height: 1.3;
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.journal-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #171a1e;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
}

.journal-table th:nth-child(1),
.journal-table td:nth-child(1) {
    width: 70px;
}

.journal-table th:nth-child(2),
.journal-table td:nth-child(2) {
    width: 27%;
}

.journal-table th:nth-child(3),
.journal-table td:nth-child(3) {
    width: 30%;
}

.journal-table th:nth-child(4),
.journal-table td:nth-child(4) {
    width: 42px;
}

.journal-table th:nth-child(5),
.journal-table td:nth-child(5) {
    width: 58px;
}

.journal-table tbody tr:last-child td {
    border-bottom: 0;
}

.date-cell {
    color: var(--accent) !important;
    font-weight: 900;
    white-space: nowrap !important;
}

.hours-cell {
    white-space: nowrap !important;
}

.notes-cell {
    overflow: visible !important;
}

.journal-note-toggle,
.journal-note-empty {
    min-height: 28px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--accent);
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
}

.journal-note-empty {
    color: var(--muted);
    cursor: default;
}

.journal-note-toggle[aria-expanded="true"] {
    border-color: rgba(255, 122, 26, 0.72);
    background: var(--accent-soft);
}

.journal-note-row td {
    padding: 8px 9px 10px 79px;
    background: rgba(255, 255, 255, 0.025);
}

.journal-note-row p {
    margin: 0;
    color: rgba(244, 245, 246, 0.82);
    font-size: 11px;
    line-height: 1.34;
    white-space: pre-wrap;
}

.empty-state {
    padding: 24px 12px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
}

@media (max-height: 680px) {
    .record-panel {
        min-height: 190px;
        grid-template-rows: 22px 92px auto auto auto;
    }

    .record-btn {
        width: 90px;
        height: 90px;
    }

    .text-area {
        min-height: 66px;
        max-height: 78px;
    }
}

@media (max-width: 380px) {
    .journal-table th,
    .journal-table td {
        padding: 0 4px;
    }

    .journal-table td {
        padding-top: 7px;
        padding-bottom: 7px;
    }

    .journal-table th:nth-child(1),
    .journal-table td:nth-child(1) {
        width: 58px;
    }

    .journal-table th:nth-child(2),
    .journal-table td:nth-child(2) {
        width: 26%;
    }

    .journal-table th:nth-child(3),
    .journal-table td:nth-child(3) {
        width: 28%;
    }

    .journal-table th:nth-child(4),
    .journal-table td:nth-child(4) {
        width: 34px;
    }

    .journal-table th:nth-child(5),
    .journal-table td:nth-child(5) {
        width: 44px;
    }
}

.admin-body {
    min-height: 100%;
    overflow: auto;
    background: #0f1114;
}

.admin-shell {
    width: min(100%, 1440px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px;
}

.admin-login {
    min-height: calc(100vh - 36px);
    display: grid;
    place-items: center;
}

.admin-login-card {
    width: min(100%, 360px);
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.admin-login-card h1,
.admin-topbar h1 {
    margin: 0;
    color: var(--accent);
    font-size: 22px;
}

.admin-topbar p {
    margin: 3px 0 0;
    color: var(--muted);
}

.admin-workspace {
    display: grid;
    gap: 12px;
}

.admin-topbar,
.admin-filters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.admin-actions,
.admin-filters {
    flex-wrap: wrap;
}

.admin-input,
.admin-table input,
.admin-table select,
.admin-table textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #101215;
    color: var(--text);
    outline: none;
}

.admin-input {
    height: 38px;
    min-width: 150px;
    padding: 0 10px;
}

.admin-primary,
.admin-secondary,
.admin-row-actions button {
    min-height: 36px;
    border: 1px solid rgba(255, 122, 26, 0.68);
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

.admin-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

.admin-table-wrap {
    max-height: calc(100vh - 135px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #101215;
}

.admin-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid var(--line);
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    padding: 6px;
    vertical-align: top;
}

.admin-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #171a1e;
    color: var(--muted);
    font-size: 11px;
    text-align: left;
    text-transform: uppercase;
}

.admin-table input,
.admin-table select,
.admin-table textarea {
    width: 100%;
    min-height: 32px;
    padding: 6px;
    font-size: 12px;
}

.admin-table textarea {
    min-height: 58px;
    resize: vertical;
}

.admin-id {
    width: 56px;
    color: var(--muted);
    font-size: 12px;
}

.admin-row-actions {
    width: 86px;
}

.admin-row-actions button {
    width: 100%;
    margin-bottom: 5px;
    min-height: 30px;
    font-size: 11px;
}

.admin-row-actions button:last-child {
    border-color: rgba(255, 90, 79, 0.6);
    color: var(--red);
    background: rgba(255, 90, 79, 0.08);
}

.admin-table tr.saved td {
    background: rgba(53, 208, 127, 0.08);
}

.admin-table [readonly],
.admin-table select:disabled {
    color: rgba(244, 245, 246, 0.78);
    background: rgba(255, 255, 255, 0.025);
}

.admin-readonly-note {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 30px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

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