:root {
    --bg: #f4f4f2;
    --panel: #ffffff;
    --text: #151515;
    --muted: #727272;
    --line: #e7e7e2;
    --primary: #111111;
    --accent: #f3cd4f;
    --danger: #b42318;
    --danger-soft: #fff0ee;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
    --radius: 18px;
    --sidebar-width: 248px;
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { min-height: 100vh; margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
[hidden] { display: none !important; }

.brand-mark {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: #111;
    background: var(--accent);
    font-weight: 900;
}

.login-body {
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 15%, rgba(243, 205, 79, 0.34), transparent 30%),
        var(--bg);
}

.login-shell { width: min(100%, 440px); }

.login-brand,
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-brand { margin: 0 0 18px 4px; }
.login-brand strong, .sidebar-brand strong { display: block; }
.login-brand span, .sidebar-brand span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }

.login-card {
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.login-heading h1 { margin: 8px 0; font-size: 30px; }
.login-heading p { margin: 0 0 24px; color: var(--muted); line-height: 1.55; }
.eyebrow { color: #6c5400; font-size: 11px; font-weight: 900; letter-spacing: 0.12em; }

.login-form { display: grid; gap: 18px; }
.login-form label { display: grid; gap: 7px; }
.login-form label > span { font-size: 13px; font-weight: 800; }
.login-form input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #d8d8d2;
    border-radius: 11px;
    color: var(--text);
    background: white;
    outline: none;
}
.login-form input:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08); }

.alert { margin-bottom: 20px; padding: 12px 14px; border-radius: 11px; font-size: 13px; line-height: 1.45; }
.alert-error { color: var(--danger); background: var(--danger-soft); border: 1px solid #ffd5cf; }
.alert-success { color: #176b3a; background: #ebfff3; border: 1px solid #bce9cd; }
.activation-note { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }

.btn {
    padding: 10px 15px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-weight: 800;
}
.btn-primary { color: white; background: var(--primary); }
.btn-light { color: var(--text); background: white; border-color: var(--line); }
.btn-danger { color: var(--danger); background: var(--danger-soft); border-color: #ffd5cf; }
.btn-small { padding: 8px 11px; font-size: 12px; }
.btn-full { width: 100%; margin-top: 4px; padding-block: 12px; }
.btn-link { display: block; text-align: center; text-decoration: none; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    color: white;
    background: #111;
}
.sidebar-brand { padding: 4px 8px 24px; }
.sidebar-brand span { color: #a8a8a8; }
.sidebar-nav { display: grid; gap: 5px; }
.sidebar-nav a, .sidebar-nav span {
    padding: 12px 13px;
    border-radius: 12px;
    color: #bdbdbd;
    text-decoration: none;
}
.sidebar-nav .active { color: #111; background: var(--accent); font-weight: 850; }
.sidebar-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding: 18px 8px 4px;
    border-top: 1px solid #292929;
    color: #a8a8a8;
    font-size: 12px;
}
.sidebar-status i { width: 8px; height: 8px; border-radius: 50%; background: #39c77a; }

.main-content { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
    min-height: 86px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
    background: rgba(244, 244, 242, 0.94);
}
.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.account-box { margin-left: auto; display: flex; align-items: center; gap: 14px; text-align: right; }
.account-box strong, .account-box span { display: block; }
.account-box span { margin-top: 3px; color: var(--muted); font-size: 12px; }

.content { max-width: 1400px; margin: 0 auto; padding: 28px; }
.welcome-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px;
    border-radius: 22px;
    background: var(--accent);
}
.welcome-card h2 { margin: 8px 0; font-size: 28px; }
.welcome-card p { margin: 0; color: #574a1a; }
.role-pill { padding: 9px 13px; border-radius: 999px; color: white; background: #111; font-size: 12px; font-weight: 850; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 18px 0; }
.stat-card, .panel { border: 1px solid var(--line); background: var(--panel); box-shadow: 0 10px 24px rgba(0,0,0,.035); }
.stat-card { min-height: 132px; padding: 20px; border-radius: var(--radius); }
.stat-card span, .stat-card strong, .stat-card small { display: block; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { margin: 12px 0 8px; font-size: 25px; }
.stat-card small { color: var(--muted); }
.panel { padding: 24px; border-radius: var(--radius); }
.panel h3 { margin: 0 0 16px; }
.check-list { margin: 0; padding-left: 22px; color: #444; line-height: 1.9; }

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
    padding: 26px 28px;
    border-radius: 22px;
    background: var(--accent);
}
.page-heading h2 { margin: 7px 0 8px; font-size: 28px; }
.page-heading p { max-width: 720px; margin: 0; color: #574a1a; line-height: 1.55; }
.page-alert { margin: 0 0 16px; }

.employee-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
    gap: 16px;
}
.employee-card {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .035);
}
.employee-card-header,
.employee-identity,
.employee-tags,
.modal-footer,
.modal-danger-actions,
.modal-primary-actions {
    display: flex;
    align-items: center;
}
.employee-card-header { justify-content: space-between; gap: 16px; }
.employee-identity { min-width: 0; gap: 12px; }
.employee-identity h3 { overflow-wrap: anywhere; margin: 0 0 4px; font-size: 18px; }
.employee-identity span { display: block; overflow-wrap: anywhere; color: var(--muted); font-size: 12px; }
.employee-color-display {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: transparent;
}
.employee-color-display::-webkit-color-swatch-wrapper { padding: 0; }
.employee-color-display::-webkit-color-swatch { border: 0; border-radius: 11px; }
.employee-tags { flex-wrap: wrap; gap: 7px; margin: 20px 0; }
.status-badge { padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-active { color: #176b3a; background: #ebfff3; }
.status-pending { color: #8a5a00; background: #fff5d8; }
.status-owner { color: white; background: #111; }
.employee-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0; }
.employee-details div { min-width: 0; padding-top: 12px; border-top: 1px solid var(--line); }
.employee-details dt { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.employee-details dd { overflow-wrap: anywhere; margin: 0; font-size: 13px; font-weight: 750; }
.loading-panel, .empty-state { grid-column: 1 / -1; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--text); }

.modal {
    width: min(880px, calc(100% - 28px));
    max-height: min(880px, calc(100vh - 28px));
    padding: 0;
    border: 0;
    border-radius: 22px;
    background: transparent;
    box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0, 0, 0, .48); backdrop-filter: blur(2px); }
.modal-card { margin: 0; background: white; }
.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 26px 20px;
    border-bottom: 1px solid var(--line);
}
.modal-header h2 { margin: 6px 0; }
.modal-header p { margin: 0; color: var(--muted); font-size: 13px; }
.icon-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--text);
    background: white;
    font-size: 24px;
    line-height: 1;
}
.modal-body { max-height: calc(100vh - 235px); overflow-y: auto; padding: 24px 26px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span, .form-section legend { font-size: 13px; font-weight: 800; }
.field small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.field input,
.field select,
.field textarea {
    width: 100%;
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid #d8d8d2;
    border-radius: 11px;
    color: var(--text);
    background: white;
    outline: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(17, 17, 17, .08); }
.field input[readonly] { color: var(--muted); background: #f5f5f2; }
.field input[type="color"] { min-height: 44px; padding: 4px; }
.form-section { margin: 22px 0 0; padding: 17px; border: 1px solid var(--line); border-radius: 14px; }
.form-section legend { padding: 0 7px; }
.form-section > p { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.day-options, .permission-options { display: flex; flex-wrap: wrap; gap: 9px; }
.day-options label,
.permission-options label {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fafaf8;
    font-size: 12px;
}
.permission-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.activation-result { margin-top: 20px; padding: 16px; border: 1px solid #e4c04d; border-radius: 13px; background: #fff8db; }
.activation-result p { margin: 6px 0 10px; color: #6e5b19; font-size: 12px; line-height: 1.5; }
.activation-result a { display: block; overflow-wrap: anywhere; color: #5a4300; font-size: 12px; }
.modal-footer { justify-content: space-between; gap: 16px; padding: 18px 26px; border-top: 1px solid var(--line); }
.modal-danger-actions, .modal-primary-actions { flex-wrap: wrap; gap: 9px; }
.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 20;
    max-width: min(420px, calc(100% - 44px));
    padding: 13px 16px;
    border-radius: 12px;
    color: white;
    background: #111;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

.appointments-content { max-width: 1680px; }
.calendar-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 14px;
    padding: 22px 24px;
    border-radius: 20px;
    background: var(--accent);
}
.calendar-toolbar h2 { margin: 6px 0 0; font-size: 25px; }
.calendar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.calendar-legend span {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
    font-size: 12px;
    font-weight: 750;
}
.calendar-legend i { width: 10px; height: 10px; border-radius: 50%; }
.week-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(165px, 1fr));
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
}
.calendar-day {
    min-height: 560px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fafaf8;
}
.calendar-day > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
}
.calendar-day > header span { font-size: 12px; font-weight: 800; }
.calendar-day > header strong {
    width: 31px;
    height: 31px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--text);
}
.calendar-day.is-today { border-color: #d4ab1e; background: #fffdf4; }
.calendar-day.is-today > header strong { background: var(--accent); }
.calendar-day-body { display: grid; align-content: start; gap: 8px; padding: 9px; }
.calendar-empty { margin: 10px 4px; color: #aaa; font-size: 12px; text-align: center; }
.appointment-card {
    width: 100%;
    display: grid;
    gap: 4px;
    padding: 11px 10px 10px 13px;
    border: 1px solid var(--line);
    border-left: 5px solid var(--employee-color);
    border-radius: 11px;
    color: var(--text);
    background: white;
    text-align: left;
    box-shadow: 0 5px 12px rgba(0, 0, 0, .035);
}
.appointment-card:hover { border-color: #cfcfc7; transform: translateY(-1px); }
.appointment-card .appointment-time { font-size: 12px; font-weight: 900; }
.appointment-card strong { overflow-wrap: anywhere; font-size: 13px; }
.appointment-card > span:not(.appointment-time) {
    overflow-wrap: anywhere;
    color: #3e3e3e;
    font-size: 12px;
}
.appointment-card small { overflow-wrap: anywhere; color: var(--muted); font-size: 10px; }
.appointment-card em {
    width: fit-content;
    margin-top: 3px;
    padding: 3px 6px;
    border-radius: 999px;
    color: #745600;
    background: #fff4cd;
    font-size: 9px;
    font-style: normal;
    font-weight: 850;
}
.appointment-card.status-completed { opacity: .72; }
.appointment-card.status-completed em { color: #176b3a; background: #ebfff3; }
.appointment-card.status-cancelled,
.appointment-card.status-no_show { opacity: .52; }
.appointment-card.status-cancelled strong,
.appointment-card.status-cancelled > span { text-decoration: line-through; }
.appointment-card.status-cancelled em,
.appointment-card.status-no_show em { color: var(--danger); background: var(--danger-soft); }
.field-wide { grid-column: 1 / -1; }
.field textarea { resize: vertical; }

@media (max-width: 980px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .calendar-toolbar { align-items: flex-start; flex-direction: column; }
    .calendar-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
    .sidebar { position: static; width: auto; min-height: auto; }
    .sidebar-brand { padding-bottom: 14px; }
    .sidebar-nav { display: flex; overflow-x: auto; padding-bottom: 2px; }
    .sidebar-nav a, .sidebar-nav span { flex: 0 0 auto; padding: 10px 12px; }
    .sidebar-status { display: none; }
    .main-content { margin-left: 0; }
    .topbar { align-items: flex-start; padding: 16px; }
    .account-box { gap: 8px; }
    .content { padding: 16px; }
    .welcome-card { align-items: flex-start; flex-direction: column; }
    .page-heading { align-items: flex-start; flex-direction: column; padding: 22px; }
    .page-heading .btn { width: 100%; }
    .form-grid, .permission-options { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
    .calendar-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
    .calendar-actions .btn { padding-inline: 9px; }
    .calendar-day { min-height: 430px; }
    .modal-footer { align-items: stretch; flex-direction: column-reverse; }
    .modal-danger-actions, .modal-primary-actions { width: 100%; }
    .modal-primary-actions .btn { flex: 1; }
}

@media (max-width: 480px) {
    .login-body { padding: 14px; }
    .login-card { padding: 24px 20px; }
    .stats-grid { grid-template-columns: 1fr; }
    .topbar p, .account-box > div { display: none; }
    .employee-grid { grid-template-columns: 1fr; }
    .employee-details { grid-template-columns: 1fr; }
    .calendar-actions { grid-template-columns: 1fr 1fr; }
    .calendar-actions .btn-primary { grid-column: 1 / -1; }
    .modal { width: calc(100% - 16px); max-height: calc(100vh - 16px); }
    .modal-header, .modal-body, .modal-footer { padding-inline: 18px; }
    .modal-danger-actions, .modal-primary-actions { display: grid; grid-template-columns: 1fr; }
}
