:root {
    --bg: #eef4f7;
    --panel: #ffffff;
    --panel-alt: #f8fbfc;
    --line: #d8e3e8;
    --text: #18323d;
    --muted: #69808a;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --danger: #c2410c;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.15), transparent 28%),
        linear-gradient(180deg, #f8fcfd 0%, var(--bg) 100%);
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 20px 24px;
    margin-bottom: 20px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
}

.topbar h1 {
    margin: 4px 0 0;
    font-size: 28px;
}

.eyebrow {
    color: var(--brand);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-links a,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
}

.nav-links a {
    background: var(--panel-alt);
    border-color: var(--line);
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

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

.btn-secondary {
    background: var(--panel-alt);
    border-color: var(--line);
    color: var(--text);
}

.btn-link {
    color: var(--brand);
}

.btn-danger {
    background: #b91c1c;
    color: #fff;
}

.btn-danger:hover {
    background: #991b1b;
}

.flash {
    margin-bottom: 20px;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fff;
}

.flash-success {
    border-color: #99f6e4;
    background: #f0fdfa;
}

.flash-error {
    border-color: #fdba74;
    background: #fff7ed;
}

.page-grid,
.detail-grid,
.customer-grid {
    display: grid;
    gap: 20px;
}

.page-grid {
    grid-template-columns: 1.3fr 0.7fr;
}

.detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.customer-grid {
    grid-template-columns: 0.8fr 1.2fr;
}

.card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(216, 227, 232, 0.9);
    border-radius: 24px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.card h2,
.card h3 {
    margin-top: 0;
}

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

.toolbar form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

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

.stat {
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 100%);
    border: 1px solid #d1fae5;
}

.stat strong {
    display: block;
    font-size: 28px;
    margin-top: 6px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

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

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

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

.full-span {
    grid-column: 1 / -1;
}

.field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    font: inherit;
    color: var(--text);
}

.field textarea {
    min-height: 110px;
    resize: vertical;
}

.items-table input {
    min-width: 0;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.empty-state {
    padding: 24px;
    border-radius: 18px;
    background: var(--panel-alt);
    border: 1px dashed var(--line);
    text-align: center;
}

.errors {
    margin: 0 0 16px;
    padding: 14px 18px;
    border-radius: 16px;
    background: #fff7ed;
    color: var(--danger);
    border: 1px solid #fdba74;
}

.summary-box {
    display: grid;
    gap: 10px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.summary-row.total {
    font-weight: 700;
    font-size: 20px;
}

.status-generated {
    color: #15803d;
    font-weight: 700;
}

.status-pending {
    color: #b91c1c;
    font-weight: 700;
}

.danger-box {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid #fecaca;
    border-radius: 18px;
    background: #fff1f2;
}

.danger-box h3 {
    color: #991b1b;
}

.inline-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
}

.inline-form .field {
    flex: 1 1 240px;
}

@media (max-width: 900px) {
    .page-grid,
    .detail-grid,
    .customer-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}
