/* ===== CSS Variables ===== */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #e2e5ea;
    --border-light: #eef0f3;
    --text: #1a1d23;
    --text-secondary: #6b7280;
    --text-hint: #9ca3af;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-light: #eff6ff;
    --success: #059669;
    --success-light: #ecfdf5;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --nav-height: 56px;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Navbar ===== */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 24px;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.navbar-brand {
    display: flex; align-items: center; gap: 8px;
    font-weight: 600; font-size: 14px; color: var(--text);
    white-space: nowrap;
}
.navbar-brand svg { color: var(--primary); }
.navbar-links {
    display: flex; align-items: center; gap: 4px;
    flex: 1;
}
.nav-link {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-light); color: var(--primary); }
.navbar-user {
    display: flex; align-items: center; gap: 12px;
    margin-left: auto;
}
.user-name { font-size: 13px; color: var(--text-secondary); }
.btn-logout {
    font-size: 12px; color: var(--text-secondary);
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.btn-logout:hover { background: var(--bg); text-decoration: none; }

/* ===== Main Layout ===== */
main.with-nav {
    margin-top: var(--nav-height);
    min-height: calc(100vh - var(--nav-height));
    padding: 32px 24px;
    max-width: 1200px;
    margin-left: auto; margin-right: auto;
    padding-top: calc(var(--nav-height) + 32px);
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
}
.page-title { font-size: 22px; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500;
    border: none; cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }
.btn-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fee2e2; text-decoration: none; }
.btn-success { background: var(--success-light); color: var(--success); border: 1px solid #6ee7b7; }
.btn-full { width: 100%; justify-content: center; }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
}
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #a7f3d0; }
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fca5a5; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.required { color: var(--danger); }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}
.form-input:disabled { background: var(--bg); color: var(--text-secondary); cursor: not-allowed; }
.form-textarea { resize: vertical; min-height: 100px; }
.form-hint { display: block; font-size: 11px; color: var(--text-hint); margin-top: 4px; }
.form-input-sm, .form-select-sm { width: auto; }

/* ===== Form Grid ===== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0 24px;
}
.form-group-center { display: flex; flex-direction: column; justify-content: center; }

/* ===== Checkbox ===== */
.checkbox-label {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; font-size: 13px; font-weight: 500;
    user-select: none;
}
.checkbox-label input[type="checkbox"] { display: none; }
.checkbox-custom {
    width: 16px; height: 16px;
    border: 2px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    transition: all 0.15s;
    flex-shrink: 0;
    position: relative;
}
.checkbox-label input:checked + .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}
.checkbox-label input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 3px; top: 0px;
    width: 5px; height: 9px;
    border: 2px solid #fff;
    border-top: none; border-left: none;
    transform: rotate(45deg);
}

/* ===== Form Sections ===== */
.request-form { max-width: 900px; }
.form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}
.section-title {
    font-size: 14px; font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.form-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 8px;
}

/* ===== Table ===== */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    background: #f8f9fb;
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafbfc; }
.td-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text-secondary); }

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-новая { background: var(--primary-light); color: var(--primary); }
.badge-отправлена { background: var(--warning-light); color: var(--warning); }
.badge-выполнена { background: var(--success-light); color: var(--success); }
.badge-urgent { background: #fef2f2; color: var(--danger); }
.badge-admin { background: #f3e8ff; color: #7c3aed; }
.badge-doctor { background: var(--primary-light); color: var(--primary); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--bg); color: var(--text-secondary); }

/* ===== Links ===== */
.link { color: var(--primary); font-size: 13px; font-weight: 500; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--danger); background: none; border: none; cursor: pointer; font-family: inherit; font-size: 13px; padding: 0; }
.link-danger:hover { text-decoration: underline; }

/* ===== Filters ===== */
.filters-bar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px; flex-wrap: wrap;
}
.filters-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.results-count { font-size: 12px; color: var(--text-secondary); margin-left: auto; }

/* ===== Detail grid ===== */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}
.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.detail-card-full { grid-column: 1 / -1; }
.detail-section-title {
    font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}
.detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.detail-list dt { font-size: 12px; color: var(--text-secondary); }
.detail-list dd { font-size: 13px; color: var(--text); font-weight: 500; }
.detail-comments { font-size: 13px; color: var(--text); line-height: 1.7; white-space: pre-wrap; }

/* ===== Two-col layout ===== */
.two-col-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.form-card-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; }

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-secondary);
    display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.empty-state svg { color: var(--border); }
.empty-state p { font-size: 14px; }

/* ===== Status form ===== */
.status-form { margin-bottom: 0; }

/* ===== Login page ===== */
.login-body {
    background: linear-gradient(135deg, #f0f4ff 0%, #f5f6f8 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
}
.login-wrap {
    width: 100%;
    max-width: 400px;
    padding: 24px;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.login-card {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 32px;
    box-shadow: var(--shadow-md);
}
.login-logo {
    text-align: center; margin-bottom: 20px;
    color: var(--primary);
}
.login-title {
    text-align: center;
    font-size: 18px; font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
}
.login-subtitle {
    text-align: center;
    font-size: 12px; color: var(--text-secondary);
    margin-bottom: 24px;
}
.login-form .form-group { margin-bottom: 14px; }
.login-footer { font-size: 11px; color: var(--text-hint); text-align: center; }
