/* === Warm Glass Design System === */

:root {
    --bg: #F0EAE3;
    --bg-glass: rgba(253, 250, 247, 0.7);
    --bg-card: rgba(253, 250, 247, 0.85);
    --border-glass: rgba(255, 255, 255, 0.4);
    --border: #E2D8CC;

    --text: #3B2E24;
    --text-secondary: #7A6B5D;
    --text-muted: #A89888;

    --primary: #C8923A;
    --primary-hover: #D9A34B;
    --accent: #B8860B;
    --success: #7A9B7A;
    --danger: #C47A7A;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 16px;
    --radius-pill: 999px;

    --shadow: 0px 6px 20px rgba(59, 46, 36, 0.06);
    --shadow-md: 0px 10px 30px rgba(59, 46, 36, 0.08);
    --shadow-lg: 0px 15px 40px rgba(59, 46, 36, 0.1);

    --transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Noto Sans SC', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    background-image:
        radial-gradient(ellipse at 20% 30%, rgba(200, 160, 120, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(180, 140, 100, 0.1) 0%, transparent 50%),
        linear-gradient(180deg, #F0EAE3 0%, #E8DDD0 100%);
    background-attachment: fixed;
    min-height: 100dvh;
}

/* ============= Glass Panel ============= */
.panel {
    background: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 16px; }

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 18px 20px 0;
}
.panel-header .icon {
    width: 32px;
    height: 32px;
    background: rgba(200, 146, 58, 0.1);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.panel-header .icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--primary);
}
.panel-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.panel-body {
    padding: 14px 20px 20px;
}

/* ============= Card ============= */
.card {
    background: var(--bg-card);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

/* ============= Button ============= */
.btn {
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(253, 250, 247, 0.5);
    color: var(--text);
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { border-color: var(--text-muted); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

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

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

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

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text); background: rgba(253, 250, 247, 0.5); }

.btn-secondary {
    background: rgba(253, 250, 247, 0.5);
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

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

/* ============= Form ============= */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: rgba(253, 250, 247, 0.6);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus { border-color: var(--primary); }

textarea.form-control { resize: vertical; }
select.form-control { cursor: pointer; }

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

/* ============= Modal ============= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(59, 46, 36, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal {
    background: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(30px);
    -webkit-backdrop-filter: saturate(180%) blur(30px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header { text-align: center; margin-bottom: 16px; }
.modal-header-left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.modal-close {
    width: 28px; height: 28px;
    border: none;
    background: rgba(200, 146, 58, 0.1);
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.modal-close:hover { background: rgba(200, 146, 58, 0.2); }

.modal-content { margin-bottom: 20px; }
.modal-content p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.modal-buttons { display: flex; flex-direction: column; gap: 8px; }

.modal-btn {
    width: 100%;
    padding: 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(253, 250, 247, 0.5);
    color: var(--text);
}
.modal-btn:active { transform: scale(0.98); }

.modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ============= Toast ============= */
.toast {
    position: fixed;
    top: 20px; right: 20px;
    padding: 10px 20px;
    background: var(--text);
    color: #fff;
    border-radius: var(--radius);
    z-index: 2000;
    font-size: 13px;
    box-shadow: var(--shadow-md);
    animation: slideIn 0.25s ease;
}

/* ============= Error ============= */
.error-container {
    text-align: center;
    padding: 40px 20px;
}
.error-container h2 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
    font-weight: 600;
}
.error-container p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.back-btn {
    padding: 9px 24px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s;
}
.back-btn:hover { background: var(--primary-hover); }

/* ============= Table ============= */
.table-wrap { overflow-x: auto; }

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

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

th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(240, 234, 227, 0.5);
}

td { font-size: 13px; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(240, 234, 227, 0.3); }

/* ============= Badge ============= */
.badge {
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 500;
    display: inline-block;
    letter-spacing: 0.01em;
}
.badge-unused {
    background: rgba(122, 155, 122, 0.12);
    color: #5B8A6B;
    border: 1px solid rgba(122, 155, 122, 0.25);
}
.badge-active {
    background: rgba(200, 146, 58, 0.12);
    color: #A67A30;
    border: 1px solid rgba(200, 146, 58, 0.25);
}
.badge-expired {
    background: rgba(196, 122, 122, 0.12);
    color: #A55050;
    border: 1px solid rgba(196, 122, 122, 0.25);
}

/* ============= Pagination ============= */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
}
.pagination button {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: rgba(253, 250, 247, 0.5);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-secondary);
    font-size: 13px;
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination span { font-size: 13px; color: var(--text-muted); }

/* ============= Filter ============= */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
    padding: 7px 12px;
    background: rgba(253, 250, 247, 0.5);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
    cursor: pointer;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--primary); }

/* ============= Loading ============= */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.6s linear infinite;
}
.loading-dark {
    border-color: rgba(200, 146, 58, 0.2);
    border-top-color: var(--primary);
}

/* ============= Navbar ============= */
.navbar {
    background: var(--bg-glass);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border-glass);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.navbar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}
.navbar-sub {
    font-size: 13px;
    color: var(--text-muted);
}

/* ============= Scrollbar ============= */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============= Animations ============= */
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.97) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
