*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f4f6fb;
    --bg-soft: #eef2f9;
    --surface: #ffffff;
    --surface-2: #f9fbff;
    --text: #111827;
    --muted: #667085;
    --border: #dce3ef;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow: 0 14px 35px -24px rgba(15, 23, 42, 0.35);
}

body {
    font-family: "Segoe UI", "Inter", sans-serif;
    background: radial-gradient(circle at top right, #eaf1ff, transparent 40%), var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    width: min(440px, 92vw);
    margin: 7vh auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2rem 1.8rem;
    box-shadow: var(--shadow);
}

.container h1 {
    font-size: 1.5rem;
    margin-bottom: 1.1rem;
}

form {
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.84rem;
    color: var(--muted);
}

input,
select,
textarea {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    padding: 0.62rem 0.76rem;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button {
    border: 0;
    border-radius: 10px;
    padding: 0.62rem 0.95rem;
    font-weight: 600;
    font-size: 0.84rem;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    box-shadow: 0 10px 18px -14px rgba(29, 78, 216, 0.8);
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease;
}

button:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.alert {
    font-size: 0.84rem;
    border-radius: 10px;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.8rem;
}

.alert-error {
    border: 1px solid #fca5a5;
    background: #fff1f2;
    color: #b91c1c;
}

.app-shell {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #0f172a, #111827);
    color: #c7d2fe;
    border-right: 1px solid rgba(148, 163, 184, 0.18);
    padding: 0.9rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.sidebar-header {
    padding: 0.55rem 0.55rem 0.25rem;
}

.sidebar-title {
    font-size: 0.73rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #93c5fd;
    font-weight: 700;
}

.sidebar-user {
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    padding: 0.7rem;
}

.sidebar-user-name {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: #bfdbfe;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
    margin-top: 0.2rem;
}

.sidebar-link {
    color: #cbd5e1;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.56rem 0.65rem;
    font-size: 0.83rem;
}

.sidebar-link:hover {
    background: rgba(59, 130, 246, 0.14);
    border-color: rgba(147, 197, 253, 0.25);
}

.sidebar-link-active {
    background: rgba(37, 99, 235, 0.22);
    border-color: rgba(147, 197, 253, 0.45);
    color: #fff;
}

.sidebar-link-danger {
    color: #fecaca;
}

.sidebar-link-danger:hover {
    background: rgba(220, 38, 38, 0.18);
    border-color: rgba(248, 113, 113, 0.35);
}

.sidebar-footer {
    margin-top: auto;
}

.content {
    padding: 1.45rem;
}

.content-header {
    margin-bottom: 1rem;
}

.content-header h1 {
    font-size: 1.45rem;
    margin-bottom: 0.2rem;
}

.content-header p {
    color: var(--muted);
    font-size: 0.88rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 1rem;
}

.users-card {
    margin-bottom: 1rem;
}

.card-header {
    margin-bottom: 0.7rem;
}

.card-header h2 {
    font-size: 1.01rem;
    margin-bottom: 0.16rem;
}

.card-subtitle {
    color: var(--muted);
    font-size: 0.8rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: var(--shadow);
    padding: 0.85rem 0.9rem;
}

.stat-label {
    color: var(--muted);
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 1.45rem;
    line-height: 1.2;
    margin-top: 0.25rem;
    font-weight: 700;
}

.stat-sub {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 0.12rem;
}

.stat-total { border-top: 3px solid #6366f1; }
.stat-missed { border-top: 3px solid #f59e0b; }
.stat-called { border-top: 3px solid #0ea5e9; }
.stat-success { border-top: 3px solid #22c55e; }

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.7rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.4rem;
}

.button {
    display: inline-flex;
    align-items: center;
    border-radius: 10px;
    padding: 0.48rem 0.75rem;
    font-size: 0.8rem;
}

.button-outline {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}

.user-form {
    margin-bottom: 0.85rem;
}

.user-form-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr auto;
    gap: 0.72rem;
}

.tables-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.82rem;
}

.table-wrapper {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: auto;
    max-height: 330px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.79rem;
}

thead {
    background: #eef4ff;
}

th,
td {
    text-align: left;
    padding: 0.48rem 0.52rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr:nth-child(even) {
    background: var(--surface-2);
}

tbody tr:hover {
    background: #ebf3ff;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.28rem;
}

.table-actions form {
    margin: 0;
}

.table-actions a {
    color: var(--primary);
    font-size: 0.74rem;
}

.table-actions button {
    background: #ef4444;
    box-shadow: none;
    padding: 0.18rem 0.5rem;
    border-radius: 6px;
    font-size: 0.71rem;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
}

.mini-input {
    width: 102px;
    padding: 0.28rem 0.42rem;
    font-size: 0.78rem;
    border-radius: 8px;
}

.mini-save {
    font-size: 0.74rem;
    border-radius: 7px;
    padding: 0.28rem 0.58rem;
    white-space: nowrap;
}

.nowrap-cell {
    white-space: nowrap;
}

.user-summary-badges {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.user-badge {
    border-radius: 999px;
    font-size: 0.73rem;
    border: 1px solid var(--border);
    background: #f7f9fd;
    padding: 0.17rem 0.5rem;
}

.user-badge-success { color: #166534; border-color: #86efac; background: #f0fdf4; }
.user-badge-failed { color: #1d4ed8; border-color: #93c5fd; background: #eff6ff; }
.user-badge-missed { color: #92400e; border-color: #fdba74; background: #fff7ed; }

.user-accordion {
    margin-top: 0.7rem;
}

.user-accordion summary {
    cursor: pointer;
    list-style: none;
    color: var(--text);
    font-size: 0.82rem;
}

.user-accordion summary::-webkit-details-marker {
    display: none;
}

.recording-card {
    margin-bottom: 1rem;
}

.recording-controls {
    display: flex;
    gap: 0.45rem;
    align-items: center;
    flex-wrap: wrap;
}

.recording-status {
    margin-top: 0.6rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.recording-timer {
    border: 1px solid var(--border);
    background: #f3f6fd;
    border-radius: 999px;
    color: #1e3a8a;
    font-size: 0.79rem;
    font-weight: 700;
    padding: 0.2rem 0.58rem;
}

.recording-preview {
    margin-top: 0.45rem;
    width: min(430px, 100%);
}

.recording-audio {
    width: 220px;
    max-width: 100%;
}

@media (max-width: 1220px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .tables-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(148, 163, 184, 0.18);
        padding: 0.8rem;
    }
    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .content {
        padding: 1rem;
    }
    .tables-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    .user-form-row {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
