:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-muted: #f1f4f8;
    --text: #151922;
    --muted: #697386;
    --line: #dde3eb;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #c2410c;
    --danger-dark: #9a3412;
    --success-bg: #e8f7ef;
    --success-text: #166534;
    --error-bg: #fff1f2;
    --error-text: #be123c;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    background:
        linear-gradient(180deg, #eef2f6 0, var(--bg) 340px),
        var(--bg);
    color: var(--text);
    letter-spacing: 0;
}

a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: #e7f4f2;
    color: var(--primary-dark);
    font-weight: 900;
    text-decoration: none;
}

.button-link:hover {
    background: #d8efec;
    color: var(--primary-dark);
    text-decoration: none;
}

.topbar {
    background: #111827;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: #fff;
}

.topbar-inner {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 22px 0;
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0;
}

.brand h1 {
    margin: 0;
    font-size: clamp(22px, 3vw, 30px);
    line-height: 1.1;
}

.brand p {
    margin: 5px 0 0;
    color: #cbd5e1;
    font-size: 14px;
}

.userbox {
    min-width: 210px;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--radius);
    background: rgba(255,255,255,.05);
    text-align: right;
}

.userbox span,
.userbox em {
    display: block;
    color: #cbd5e1;
    font-size: 12px;
    font-style: normal;
}

.userbox strong {
    display: block;
    margin: 2px 0;
    font-size: 15px;
}

.nav {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.nav-inner {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 10px 0;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.nav a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 9px 13px;
    border-radius: var(--radius);
    color: #334155;
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
}

.nav a:hover,
.nav a.active {
    background: #e7f4f2;
    color: var(--primary-dark);
}

.nav .logout-link {
    margin-left: auto;
    color: #9f1239;
}

.nav .logout-link:hover {
    background: #fff1f2;
    color: #9f1239;
}

.container {
    width: min(1280px, calc(100% - 32px));
    margin: 24px auto 0;
    padding: 0 0 36px;
}

.card {
    overflow-x: auto;
    margin-bottom: 18px;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card h2,
.card h3 {
    margin: 0 0 16px;
    color: var(--text);
    line-height: 1.2;
}

.card h2 {
    font-size: 24px;
}

.card h3 {
    font-size: 18px;
}

.card p {
    color: var(--muted);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .06);
}

.stat strong {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.stat span {
    color: var(--text);
    font-size: 34px;
    font-weight: 850;
    line-height: 1;
}

.stat-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.stat-link:hover {
    border-color: var(--primary);
    color: inherit;
    text-decoration: none;
}

label {
    display: block;
    margin-bottom: 7px;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    margin-bottom: 14px;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .13);
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 16px;
    border: 0;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}

button:hover {
    background: var(--primary-dark);
    box-shadow: 0 10px 20px rgba(15, 118, 110, .18);
    transform: translateY(-1px);
}

button.danger {
    background: var(--danger);
}

button.danger:hover {
    background: var(--danger-dark);
    box-shadow: 0 10px 20px rgba(194, 65, 12, .18);
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-muted);
    color: #475569;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

tr:hover td {
    background: #fbfcfd;
}

.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-weight: 700;
}

.success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #bbf7d0;
}

.error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: #fecdd3;
}

.login-box {
    max-width: 440px;
    margin: 56px auto;
}

.login-box button {
    width: 100%;
}

.small {
    color: var(--muted);
    font-size: 14px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

.status-new {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.status-progress {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #c2410c;
}

.status-done {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #15803d;
}

.status-paid {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.status-cancelled {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

.status-default {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

.compact-form input,
.compact-form textarea,
.compact-form select {
    min-width: 220px;
}

.inline-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pending-edit {
    min-width: 260px;
    padding: 12px;
    border: 1px solid #bae6fd;
    border-radius: var(--radius);
    background: #f0f9ff;
}

.pending-edit.wide {
    min-width: 0;
}

.filter-form .inline-form {
    margin-top: 2px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.page-heading p {
    margin: 4px 0 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.detail-grid > div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.detail-grid strong {
    display: block;
    margin-top: 5px;
}

.two-columns {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.details-list {
    margin: 0;
}

.details-list dt {
    margin-top: 14px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.details-list dt:first-child {
    margin-top: 0;
}

.details-list dd {
    margin: 5px 0 0;
    color: var(--text);
    font-weight: 700;
}

.timeline {
    display: grid;
    gap: 12px;
}

.timeline-item {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.timeline-item .small {
    display: block;
    margin-top: 3px;
}

.timeline-item p {
    margin: 10px 0 0;
    color: var(--text);
}

.note-form {
    margin-bottom: 18px;
}

.notes-list {
    display: grid;
    gap: 12px;
}

.note-item {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fbfcfd;
}

.note-item .small {
    display: block;
    margin-top: 3px;
}

.note-item p {
    margin: 10px 0 0;
    color: var(--text);
}

.footer {
    margin-top: 28px;
    padding: 20px 0 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 14px;
}

.footer strong {
    color: var(--text);
}

@media (max-width: 700px) {
    .topbar-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .userbox {
        width: 100%;
        text-align: left;
    }

    .nav .logout-link {
        margin-left: 0;
    }

    .card {
        padding: 16px;
    }

    .brand h1 {
        font-size: 22px;
    }
}
