:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

* {
    box-sizing: border-box;
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 20px;
}

.topbar {
    background: #111827;
    color: #f9fafb;
    box-shadow: var(--shadow);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 58px;
    flex-wrap: wrap;
}

.brand {
    color: #ffffff;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: .2px;
}

.brand:hover {
    text-decoration: none;
}

.nav {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.nav a {
    color: #d1d5db;
    font-size: 14px;
}

.nav a:hover {
    color: #ffffff;
    text-decoration: none;
}

.nav-user {
    color: #9ca3af;
    font-size: 14px;
}

.inline-form {
    display: inline;
    margin: 0;
}

.link-button {
    background: none;
    border: 0;
    color: #d1d5db;
    font: inherit;
    font-size: 14px;
    padding: 0;
    cursor: pointer;
}

.link-button:hover {
    color: #ffffff;
}

main.container {
    padding-top: 28px;
    padding-bottom: 40px;
    min-height: calc(100vh - 150px);
}

h1 {
    font-size: 26px;
    margin: 0 0 4px;
}

h2 {
    font-size: 16px;
    margin: 0 0 14px;
    color: #374151;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.breadcrumbs {
    margin-bottom: 14px;
    font-size: 14px;
}

.filters {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.filters input[type="search"] {
    flex: 1 1 260px;
}

input,
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover {
    background: #f9fafb;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-link {
    border-color: transparent;
    background: transparent;
    color: var(--primary);
}

.btn-link:hover {
    background: transparent;
    text-decoration: underline;
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table thead th {
    background: #f9fafb;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

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

.table tbody tr:hover {
    background: #f9fafb;
}

.table tfoot th {
    background: #f9fafb;
    border-bottom: 0;
}

.num {
    text-align: right;
    white-space: nowrap;
}

.order-link {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: #e5e7eb;
    color: #374151;
}

.status-new { background: #dbeafe; color: #1d4ed8; }
.status-confirmed { background: #ede9fe; color: #6d28d9; }
.status-in_progress { background: #fef3c7; color: #b45309; }
.status-done { background: #dcfce7; color: #15803d; }
.status-cancelled { background: #fee2e2; color: #b91c1c; }
.status-questions_to_tm { background: #fef9c3; color: #a16207; }
.status-review { background: #cffafe; color: #0e7490; }
.status-rework { background: #ffedd5; color: #c2410c; }
.status-model_check { background: #fce7f3; color: #be185d; }
.status-release { background: #dcfce7; color: #15803d; }
.status-transferred { background: #e0e7ff; color: #3730a3; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 18px;
}

.card-value {
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 4px;
}

.card p {
    margin: 0 0 6px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.grid .card {
    margin-bottom: 0;
}

.section-card {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.section-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(37, 99, 235, .12);
    text-decoration: none;
}

.meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    margin: 10px 0 0;
    font-size: 14px;
}

.meta dt {
    color: var(--muted);
}

.meta dd {
    margin: 0;
}

.status-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}

.status-form select {
    flex: 1;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.field:last-child {
    grid-column: 1 / -1;
}

.has-error input,
.has-error select,
.has-error textarea {
    border-color: var(--danger);
}

.error-text {
    color: var(--danger);
    font-size: 12px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 6px;
}

.messages {
    margin-bottom: 18px;
}

.message {
    padding: 11px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    background: #e0f2fe;
    color: #075985;
    border: 1px solid #bae6fd;
}

.message.success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.message.error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.message.warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }

.empty-state {
    background: var(--surface);
    border: 1px dashed #d1d5db;
    border-radius: var(--radius);
    padding: 48px 20px;
    text-align: center;
    color: var(--muted);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.footer {
    color: var(--muted);
    font-size: 12px;
    padding-bottom: 24px;
}

.file-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.file-actions .inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.file-actions input[type="text"],
.file-actions input[type="file"] {
    width: auto;
    max-width: 240px;
}

.file-actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.file-actions-cell .inline-form {
    margin: 0;
}

@media (max-width: 640px) {
    .hide-sm {
        display: none !important;
    }

    .nav {
        gap: 12px;
    }
}
