:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --line: #dfe6f1;
    --text: #1d2b39;
    --muted: #63748a;
    --primary: #1f6feb;
    --primary-dark: #134eb0;
    --success: #1f9d61;
    --danger: #c0392b;
    --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

h1, h2, p {
    margin-top: 0;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card,
.panel,
.stat-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.login-card {
    width: min(100%, 420px);
    padding: 28px;
}

.login-card h1 {
    margin-bottom: 8px;
    font-size: 2rem;
}

.subtitle {
    color: var(--muted);
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text);
}

input, select, textarea, button {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--line);
    padding: 10px 12px;
    font-size: 0.98rem;
    margin-top: 0;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid rgba(31, 111, 235, 0.15);
    border-color: var(--primary);
}

button {
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: background 0.15s ease;
}

button:hover {
    background: var(--primary-dark);
}

button.danger-btn,
.danger-btn {
    background: var(--danger);
}

button.danger-btn:hover,
.danger-btn:hover {
    background: #a6271b;
}

.dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.topbar h1 {
    margin-bottom: 6px;
}

.top-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.message {
    margin-bottom: 18px;
    border-radius: 10px;
    padding: 12px 14px;
    font-weight: 600;
}

.message.success {
    background: rgba(31, 157, 97, 0.12);
    color: var(--success);
    border: 1px solid rgba(31, 157, 97, 0.2);
}

.message.error,
.error-box {
    background: rgba(192, 57, 43, 0.1);
    color: #8c261d;
    border: 1px solid rgba(192, 57, 43, 0.18);
}

.error-box {
    max-width: 800px;
    margin: 40px auto;
    padding: 24px;
    border-radius: 14px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-box {
    padding: 18px 20px;
}

.stat-box span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.stat-box strong {
    font-size: 2rem;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 22px;
}

.panel {
    padding: 20px;
}

.order-form {
    display: grid;
    gap: 12px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-link {
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    color: var(--text);
    background: #f4f7fb;
}

.filter-link.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

th, td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    background: #f1f5fb;
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.table-wrap table td {
    vertical-align: middle;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0;
}

.inline-form select {
    min-width: 120px;
    margin: 0;
}

.inline-form button {
    width: auto;
    min-width: 70px;
    padding: 8px 12px;
}

.delete-form {
    justify-content: flex-start;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 28px 10px;
}

.small-note {
    margin-top: 18px;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.checkbox-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f9fbff;
}

.checkbox-row input {
    width: auto;
    margin: 0;
    transform: scale(1.2);
}

.template-hint {
    margin: -4px 0 12px;
    color: var(--muted);
    font-size: 0.85rem;
}

.gear-button,
.primary-btn,
.secondary-btn,
.danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 700;
    border: 1px solid transparent;
    color: #fff;
    background: var(--primary);
    cursor: pointer;
}

.gear-button:hover,
.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover {
    opacity: 0.96;
}

.secondary-btn {
    background: #5c6f88;
}

.status-email-block {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafcff;
    margin-bottom: 18px;
}

.status-email-block h3 {
    margin: 0 0 12px;
}

.full-width-panel {
    width: 100%;
}

.action-stack {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    min-height: 42px;
}

.small-btn {
    padding: 8px 10px;
    font-size: 0.84rem;
    line-height: 1;
    min-height: 38px;
}

.danger-order-btn {
    background: #d93832 !important;
    border-color: #c82f2a !important;
    color: #ffffff !important;
}

.success-order-btn {
    background: #1f9d61 !important;
    border-color: #188352 !important;
    color: #ffffff !important;
}

.table-wrap a {
    text-decoration: none;
}

.table-wrap a:not(.secondary-btn) {
    color: var(--primary);
    font-weight: 700;
}

.table-wrap a:not(.secondary-btn):hover {
    text-decoration: underline;
}

.order-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.order-summary-grid p,
.notes-box p,
.timeline-content p {
    margin: 6px 0 0;
    color: var(--muted);
}

.notes-box {
    margin-top: 18px;
    border: 1px solid var(--line);
    background: #f9fbff;
    border-radius: 12px;
    padding: 16px;
}

.timeline {
    position: relative;
    margin-top: 18px;
    padding-left: 24px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--line);
}

.timeline-item {
    position: relative;
    margin-bottom: 18px;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--line);
}

.timeline-content {
    background: #f9fbff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
}

.timeline-content span {
    display: inline-block;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.82rem;
}

.history-table {
    min-width: 100%;
}

.history-table th,
.history-table td {
    white-space: normal;
}

@media (max-width: 640px) {
    .topbar,
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard {
        padding: 16px;
    }
}
