:root {
    --bg: #f4f5f7;
    --sidebar-bg: #14161f;
    --sidebar-text: #a6a9b8;
    --sidebar-text-active: #ffffff;
    --sidebar-accent: #6366f1;
    --card-bg: #ffffff;
    --text: #1a1c23;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand {
    color: var(--sidebar-text-active);
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 1.75rem;
    padding: 0 0.5rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
}

.sidebar nav a {
    color: var(--sidebar-text);
    text-decoration: none;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    font-size: 0.92rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,0.06);
    color: var(--sidebar-text-active);
}

.sidebar nav a.active {
    background: var(--sidebar-accent);
    color: white;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.link-button {
    background: none;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    font: inherit;
    padding: 0.55rem 0.75rem;
    width: 100%;
    text-align: left;
    border-radius: 8px;
}
.link-button:hover { background: rgba(255,255,255,0.06); color: var(--sidebar-text-active); }

.content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1100px;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-tile {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.stat-tile .stat-label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.stat-tile .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
}

.stat-tile .stat-value.accent { color: var(--accent); }
.stat-tile .stat-value.warning { color: var(--warning); }

table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
}
th { color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }
tr:last-child td { border-bottom: none; }

form.inline { display: inline; }

label { display: block; margin-bottom: 0.25rem; font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.85rem;
    font: inherit;
    background: white;
    color: var(--text);
}
textarea { resize: vertical; min-height: 80px; }

button, .button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}
button:hover, .button:hover { background: var(--accent-hover); }
button.danger { background: var(--danger); }
button.secondary { background: white; color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: #f9fafb; }

.error { color: var(--danger); margin-bottom: 1rem; }
.success { color: var(--success); margin-bottom: 1rem; }
.muted { color: var(--muted); font-size: 0.88rem; }

.login-card { max-width: 360px; width: 100%; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-open { background: #fef3c7; color: #92400e; }
.badge-in_progress { background: #dbeafe; color: #1e40af; }
.badge-closed { background: #dcfce7; color: #166534; }
.badge-urgent { background: #fee2e2; color: #991b1b; }
.badge-normal { background: #f3f4f6; color: #4b5563; }
.badge-generated { background: #dcfce7; color: #166534; }
.badge-regenerated { background: #dbeafe; color: #1e40af; }
.badge-draft { background: #f3f4f6; color: #4b5563; }
.badge-void { background: #fee2e2; color: #991b1b; }

@media (max-width: 720px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 0.75rem 1rem; }
    .sidebar .brand { margin-bottom: 0; margin-right: 1rem; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-footer { margin-top: 0; margin-left: auto; padding-top: 0; border-top: none; }
    .content { padding: 1.25rem; }
}
