/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #222;
    background: #f5f5f5;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Nav === */
.nav {
    display: flex;
    align-items: center;
    gap: 0;
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
    padding: 0 20px;
    height: 48px;
    font-size: 13px;
}

.nav-brand {
    font-weight: 600;
    color: #333;
    margin-right: 24px;
    white-space: nowrap;
    text-decoration: none;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    height: 48px;
    padding: 0 14px;
    color: #555;
    border-bottom: 2px solid transparent;
    transition: border-color .15s, color .15s;
}

.nav-link:hover {
    color: #111;
    border-bottom-color: #2563eb;
    text-decoration: none;
}

.nav-spacer { flex: 1; }

.nav-user {
    color: #333;
    font-weight: 500;
    font-size: 12px;
    margin-right: 4px;
}

.nav-logout {
    color: #888;
    font-size: 12px;
}
.nav-logout:hover { color: #ef4444; border-bottom-color: #ef4444; }

/* === Main === */
.main {
    max-width: 960px;
    margin: 24px auto;
    padding: 0 20px;
}

h1 { font-size: 22px; font-weight: 600; margin-bottom: 16px; }
h2 { font-size: 16px; font-weight: 600; margin: 8px 0 10px; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
    color: #333;
    transition: background .15s, border-color .15s;
}

.btn:hover { background: #f0f0f0; }

.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn-secondary { background: #6b7280; color: #fff; border-color: #6b7280; }
.btn-secondary:hover { background: #4b5563; }

.btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-danger:hover { background: #dc2626; }

.btn-outline { background: #fff; color: #555; }

.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-lg { padding: 8px 20px; font-size: 14px; }

/* === Forms === */
.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
}

input, select, textarea {
    padding: 5px 8px;
    font-size: 13px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
}

input:focus, select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }

.hint {
    font-size: 11px;
    color: #888;
}

.required { color: #ef4444; }

/* === Table === */
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    overflow: hidden;
}

.table th, .table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 13px;
}

.table th {
    background: #fafafa;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #666;
}

.table tr:last-child td { border-bottom: none; }

.table .empty {
    text-align: center;
    color: #999;
    padding: 24px;
}

/* === Stats === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 16px;
}

.stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #888;
    letter-spacing: .5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #111;
}

.stat-positive .stat-value { color: #16a34a; }
.stat-negative .stat-value { color: #ef4444; }

/* === Filter form === */
.filter-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-form label {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* === Status tags === */
.status-cell { display: flex; gap: 4px; flex-wrap: wrap; }

.status-tag {
    display: inline-block;
    padding: 2px 7px;
    font-size: 11px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 3px;
    white-space: nowrap;
}

/* === Checkbox group === */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 12px 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
    padding: 2px 0;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
}

/* === Detail page === */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.detail-block {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 12px;
}

.detail-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #888;
    letter-spacing: .5px;
}

.detail-value {
    font-size: 14px;
    font-weight: 500;
    color: #111;
}

/* === Order form === */
.order-form { }
.order-form h2 { margin-top: 20px; }

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-row label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
}

/* === Action icons === */
.actions-cell {
    white-space: nowrap;
    text-align: center;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    font-size: 14px;
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    transition: background .15s;
    vertical-align: middle;
}

.icon-btn:hover { background: #f0f0f0; }

.icon-delete {
    color: #ef4444;
    background: none;
    padding: 0;
}

.icon-delete:hover { background: #fef2f2; }

/* === Login page === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #f0f2f5;
}

.login-box {
    background: #fff;
    border-radius: 8px;
    padding: 36px 32px;
    width: 360px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 20px;
}

.login-box label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 14px;
}

.login-box input {
    padding: 8px 10px;
    font-size: 14px;
}

.login-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 14px;
    border: 1px solid #fecaca;
}

/* === Charts === */
.charts-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.chart-box {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 14px;
    flex: 1 1 260px;
    min-width: 240px;
    max-width: 100%;
}

.chart-box h3 {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.chart-svg {
    display: block;
    width: 100%;
    height: auto;
}

/* === Flash messages === */
.flash {
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}

.flash-ok {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.flash-err {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

/* === Sort links === */
.sort-link {
    color: #555;
    text-decoration: none;
    white-space: nowrap;
}

.sort-link:hover {
    color: #111;
    text-decoration: none;
}

.sort-arrow {
    font-size: 10px;
    margin-left: 2px;
    color: #2563eb;
}

/* === Production === */
.prod-done,
.prod-done td {
    background: #e8e8e8 !important;
}

.cb-cell {
    text-align: center;
    vertical-align: middle;
}

.cb-cell input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #16a34a;
    cursor: pointer;
}
