/* ================================================================
   货柜发货记录系统 — Global Stylesheet
   Design: Google Material / Simple Business Blue
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap');

/* ── Reset & CSS Variables ───────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Brand Blue Palette */
    --primary:          #1a73e8;
    --primary-dark:     #1557b0;
    --primary-darker:   #0d47a1;
    --primary-light:    #e8f0fe;
    --primary-medium:   #c5d8fb;
    --primary-hover:    rgba(26, 115, 232, 0.08);

    /* Neutrals */
    --surface:          #ffffff;
    --background:       #f8f9fa;
    --on-surface:       #202124;
    --on-surface-2:     #3c4043;
    --on-surface-muted: #5f6368;
    --on-surface-faint: #80868b;

    /* Borders */
    --border:           #dadce0;
    --border-light:     #e8eaed;

    /* Semantic */
    --success:          #34a853;
    --success-bg:       #e6f4ea;
    --success-border:   #a8d5b5;
    --warning:          #f9ab00;
    --warning-bg:       #fef7e0;
    --warning-border:   #f0c030;
    --error:            #d93025;
    --error-bg:         #fce8e6;
    --error-border:     #f0a9a5;

    /* Settled Row */
    --settled-row-bg:   #f1f3f4;
    --settled-text:     #5f6368;

    /* Shadows */
    --shadow-xs:  0 1px 2px rgba(60,64,67,.20);
    --shadow-sm:  0 1px 2px rgba(60,64,67,.30), 0 1px 3px 1px rgba(60,64,67,.15);
    --shadow-md:  0 1px 3px rgba(60,64,67,.30), 0 4px 8px 3px rgba(60,64,67,.12);
    --shadow-lg:  0 4px 8px rgba(60,64,67,.20), 0 6px 20px rgba(60,64,67,.15);
    --shadow-hdr: 0 2px 4px -1px rgba(0,0,0,.25), 0 4px 5px rgba(0,0,0,.14);

    /* Typography */
    --font: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    /* Spacing & Shape */
    --header-h:   64px;
    --radius-sm:  4px;
    --radius:     8px;
    --radius-lg:  12px;
    --radius-xl:  16px;
    --transition: 0.18s ease;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--background);
    color: var(--on-surface);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ── App Header ──────────────────────────────────────────────────── */
.app-header {
    background: var(--primary);
    height: var(--header-h);
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 200;
    box-shadow: var(--shadow-hdr);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 28px;
    max-width: 1700px;
    margin: 0 auto;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
}
.header-brand:hover { text-decoration: none; }

.brand-icon {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.18);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-title {
    font-size: 17px;
    font-weight: 500;
    color: #fff;
    letter-spacing: 0.3px;
    line-height: 1.2;
}
.brand-subtitle {
    font-size: 11px;
    color: rgba(255,255,255,0.7);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 22px;
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.3px;
    transition: background var(--transition), box-shadow var(--transition),
                border-color var(--transition), opacity var(--transition);
    user-select: none;
}
.btn:hover { text-decoration: none; }
.btn svg { flex-shrink: 0; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-xs);
}
.btn-primary:active { background: var(--primary-darker); }

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

.btn-ghost {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-color: rgba(255,255,255,0.35);
    backdrop-filter: blur(4px);
}
.btn-ghost:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.55);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-danger {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}
.btn-danger:hover { background: #b71c1c; border-color: #b71c1c; }

.btn-icon-only {
    padding: 7px;
    border-radius: 50%;
    background: transparent;
    border-color: transparent;
}
.btn-icon-only:hover { background: var(--primary-hover); }

/* ── Page Layout ─────────────────────────────────────────────────── */
.page-body {
    margin-top: var(--header-h);
    min-height: calc(100vh - var(--header-h));
}

.page-wrap {
    padding: 24px 28px;
    max-width: 1700px;
    margin: 0 auto;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
    border-width: 1px;
    border-style: solid;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-error   { background: var(--error-bg);   color: #7d1f1a; border-color: var(--error-border); }
.alert-success { background: var(--success-bg); color: #1a6632; border-color: var(--success-border); }
.alert-warning { background: var(--warning-bg); color: #6b4a00; border-color: var(--warning-border); }
.alert-info    { background: var(--primary-light); color: var(--primary-darker); border-color: var(--primary-medium); }

/* ── Stats Bar ───────────────────────────────────────────────────── */
.stats-bar {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--primary-light);
    border-bottom: 1px solid var(--primary-medium);
    flex-wrap: wrap;
    overflow: hidden;
}

.stat-item {
    display: flex;
    flex-direction: column;
    padding: 12px 24px;
    border-right: 1px solid var(--primary-medium);
    min-width: 140px;
}
.stat-item:last-child { border-right: none; }

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--primary-dark);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 2px;
}
.stat-value {
    font-size: 18px;
    font-weight: 500;
    color: var(--primary-darker);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.stat-value.small { font-size: 14px; }

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 4px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-wrap: wrap;
    gap: 8px;
}

.tabs-nav {
    display: flex;
    align-items: center;
}

.tab-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--on-surface-muted);
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: color var(--transition), border-color var(--transition), background var(--transition);
    white-space: nowrap;
}
.tab-link:hover {
    color: var(--primary);
    background: var(--primary-hover);
    text-decoration: none;
}
.tab-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
}
.tab-link.active .tab-count {
    background: var(--primary);
    color: #fff;
}

.tabs-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

/* ── Data Table ──────────────────────────────────────────────────── */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    min-width: 900px;
}

.data-table thead th {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 11px 14px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--primary-medium);
    position: sticky;
    top: 0;
    z-index: 10;
}
.data-table thead th.center { text-align: center; }
.data-table thead th.right  { text-align: right; }

.data-table tbody tr {
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(26,115,232,.035); }

.data-table tbody tr.settled-row { background: var(--settled-row-bg); }
.data-table tbody tr.settled-row:hover { background: #e4e7ea; }

.data-table td {
    padding: 11px 14px;
    color: var(--on-surface);
    vertical-align: middle;
}
.data-table td.center { text-align: center; }
.data-table td.right  { text-align: right; }

.col-id {
    width: 60px;
    font-weight: 700;
    font-size: 13px;
    color: var(--on-surface-muted);
}
.col-money {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    white-space: nowrap;
    color: var(--on-surface-2);
}
.col-actions { width: 80px; }
.col-date { white-space: nowrap; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px 3px 8px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.4;
}
.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.badge-settled {
    background: var(--success-bg);
    color: #1a6632;
    border: 1px solid var(--success-border);
}
.badge-settled .badge-dot { background: var(--success); }

.badge-unsettled {
    background: var(--warning-bg);
    color: #6b4a00;
    border: 1px solid var(--warning-border);
}
.badge-unsettled .badge-dot { background: var(--warning); }

/* ── Attachment ──────────────────────────────────────────────────── */
.attach-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--primary);
    font-size: 13px;
    text-decoration: none;
    padding: 3px 8px 3px 6px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    border: 1px solid var(--primary-medium);
    transition: background var(--transition);
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
}
.attach-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attach-link:hover {
    background: var(--primary-medium);
    text-decoration: none;
}
.no-attach {
    color: var(--on-surface-faint);
    font-size: 12px;
    font-style: italic;
}

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
    color: var(--on-surface-muted);
    text-align: center;
    gap: 12px;
}
.empty-icon {
    width: 72px;
    height: 72px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.empty-state h3 { font-size: 16px; font-weight: 500; color: var(--on-surface-2); }
.empty-state p  { font-size: 14px; max-width: 340px; }

/* ── Record Count ────────────────────────────────────────────────── */
.result-meta {
    padding: 10px 16px;
    font-size: 12.5px;
    color: var(--on-surface-muted);
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Login Page ──────────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(26,115,232,.12) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(66,133,244,.10) 0%, transparent 50%),
        var(--background);
    padding: 24px;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 44px 40px 36px;
    border: 1px solid var(--border-light);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 6px 16px rgba(26,115,232,.35);
    margin-bottom: 20px;
}
.login-logo h2 {
    font-size: 21px;
    font-weight: 500;
    color: var(--on-surface);
    margin-bottom: 6px;
    letter-spacing: 0.2px;
}
.login-logo p {
    font-size: 14px;
    color: var(--on-surface-muted);
}

/* ── Form Elements ───────────────────────────────────────────────── */
.form-section { margin-bottom: 0; }

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 20px;
}
.form-grid-2 .span-2 { grid-column: 1 / -1; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--on-surface-muted);
    letter-spacing: 0.2px;
}
.form-label .req { color: var(--error); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    color: var(--on-surface);
    background: var(--surface);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    line-height: 1.5;
    appearance: none;
    -webkit-appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,.18);
    background: #fff;
}
.form-input::placeholder { color: var(--on-surface-faint); }
.form-textarea {
    resize: vertical;
    min-height: 90px;
}
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%235f6368' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-hint {
    font-size: 12px;
    color: var(--on-surface-faint);
}
.form-hint.error { color: var(--error); }

/* File Input */
.file-wrap {
    position: relative;
}
.file-label-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--on-surface-muted);
    font-size: 13.5px;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
    background: #fafbfc;
    user-select: none;
}
.file-label-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.file-label-btn.has-file {
    border-color: var(--success);
    color: var(--success);
    background: var(--success-bg);
}
.file-real-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
    width: 100%;
}

/* Current Attachment Preview */
.current-attach {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--primary-light);
    border: 1px solid var(--primary-medium);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 13px;
}
.current-attach-name {
    flex: 1;
    min-width: 0;
    color: var(--primary-dark);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.current-attach-name a { color: var(--primary-dark); text-decoration: none; }
.current-attach-name a:hover { text-decoration: underline; }

.btn-remove-attach {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: none;
    border: 1px solid var(--error-border);
    border-radius: 4px;
    color: var(--error);
    font-size: 12px;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-remove-attach:hover { background: var(--error-bg); }

/* Auth Code Section */
.auth-box {
    margin-top: 24px;
    padding: 18px 20px;
    background: #fffde7;
    border: 1.5px solid #ffe082;
    border-radius: var(--radius);
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}
.auth-box-info {
    flex: 1;
    min-width: 200px;
}
.auth-box-label {
    font-size: 12.5px;
    font-weight: 600;
    color: #5d4037;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.auth-box .form-input {
    background: #fff;
    border-color: #ffca28;
}
.auth-box .form-input:focus {
    border-color: #f9a825;
    box-shadow: 0 0 0 3px rgba(249,168,37,.2);
}

/* Form Actions */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 20px;
    margin-top: 24px;
    border-top: 1px solid var(--border-light);
}

/* ── Form Page Layout ────────────────────────────────────────────── */
.form-page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}
.form-page-title {
    font-size: 19px;
    font-weight: 500;
    color: var(--on-surface);
}

/* ── Divider ─────────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 22px 0;
}
.section-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--on-surface-muted);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 18px;
}

/* ── Tooltip (title fallback) ────────────────────────────────────── */
[title] { cursor: help; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .page-wrap { padding: 16px; }
    .header-inner { padding: 0 16px; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .form-grid-2 .span-2 { grid-column: 1; }
    .data-table { font-size: 12.5px; }
    .data-table td, .data-table th { padding: 9px 10px; }
    .stat-item { min-width: 120px; padding: 10px 16px; }
    .stat-value { font-size: 16px; }
    .auth-box { flex-direction: column; }
}

@media (max-width: 480px) {
    .login-card { padding: 32px 24px 28px; }
    .brand-subtitle { display: none; }
    .tabs-bar { gap: 4px; }
    .tab-link { padding: 12px 14px; font-size: 13px; }
}
