/* ============ Основен изглед ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: #f1f4f8;
    color: #1e293b;
    font-size: 14px;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ============ Странично меню ============ */
.sidebar {
    width: 230px;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.brand {
    padding: 20px 18px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #1e293b;
}
.sidebar nav { flex: 1; padding: 10px 0; }
.sidebar nav a {
    display: block;
    padding: 11px 18px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #1e293b; color: #fff; border-left-color: #3b82f6; }
.sidebar-footer { padding: 15px 18px; border-top: 1px solid #1e293b; font-size: 13px; }
.sidebar-footer .user-name { margin-bottom: 6px; }
.sidebar-footer .logout { color: #f87171; }

/* ============ Съдържание ============ */
.content { flex: 1; padding: 24px 28px; max-width: 1250px; }
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 10px;
}
.page-header h1 { font-size: 22px; font-weight: 600; }

/* ============ Карти ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 22px; }
.card {
    background: #fff;
    border-radius: 10px;
    padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.card .card-label { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: .4px; }
.card .card-value { font-size: 22px; font-weight: 700; margin-top: 6px; }
.card .card-sub { font-size: 12px; color: #94a3b8; margin-top: 3px; }
.card-green .card-value { color: #16a34a; }
.card-red .card-value { color: #dc2626; }
.card-blue .card-value { color: #2563eb; }

.panel {
    background: #fff;
    border-radius: 10px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    margin-bottom: 20px;
}
.panel h2 { font-size: 16px; margin-bottom: 12px; }

/* ============ Таблици ============ */
table.grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
table.grid th {
    text-align: left;
    padding: 10px 12px;
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}
table.grid td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; }
table.grid tr:last-child td { border-bottom: none; }
table.grid tr:hover td { background: #f8fafc; }
td.num, th.num { text-align: right; }
.panel table.grid { box-shadow: none; }

/* ============ Бутони ============ */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 7px;
    border: none;
    background: #2563eb;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: #1d4ed8; text-decoration: none; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-green { background: #16a34a; }
.btn-green:hover { background: #15803d; }
.btn-light { background: #e2e8f0; color: #1e293b; }
.btn-light:hover { background: #cbd5e1; color: #1e293b; }

/* ============ Форми ============ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12.5px; font-weight: 600; color: #475569; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=email], select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: #3b82f6; }
textarea { resize: vertical; min-height: 60px; }

/* ============ Значки ============ */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #e2e8f0; color: #475569; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-orange { background: #ffedd5; color: #9a3412; }

/* ============ Съобщения ============ */
.flash { padding: 11px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* ============ Вход ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
}
.login-box {
    background: #fff;
    padding: 36px;
    border-radius: 14px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 10px 40px rgba(0,0,0,.35);
}
.login-box h1 { font-size: 22px; margin-bottom: 4px; }
.login-box .subtitle { color: #64748b; font-size: 13.5px; margin-bottom: 22px; }
.login-box .btn { width: 100%; padding: 11px; margin-top: 6px; }

/* ============ Редове на документ ============ */
#items-table input, #items-table select { font-size: 13.5px; padding: 6px 8px; }
#items-table td { padding: 5px 6px; }
.totals-box { text-align: right; margin-top: 12px; font-size: 15px; }
.totals-box .grand { font-size: 19px; font-weight: 700; }

.filter-bar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .form-group { margin-bottom: 0; }

.text-muted { color: #94a3b8; }
.text-red { color: #dc2626; }
.text-green { color: #16a34a; }
.mt { margin-top: 16px; }

@media (max-width: 800px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .content { padding: 16px; }
}
