:root {
    --sidebar: #111827;
    --sidebar-hover: #1f2937;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --background: #f3f4f6;
    --surface: #ffffff;
    --border: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --shadow: 0 8px 24px rgba(15, 23, 42, .07);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
    color: var(--text);
    background: var(--background);
}

a { color: inherit; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(135deg, #0f172a, #1d4ed8);
}

.login-card {
    width: min(430px, 94vw);
    background: white;
    border-radius: 20px;
    padding: 42px;
    box-shadow: 0 25px 70px rgba(0,0,0,.3);
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    background: var(--sidebar);
    color: white;
    z-index: 50;
}

.brand {
    min-height: 84px;
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--primary);
    font-weight: 800;
    font-size: 22px;
}

.brand strong, .brand small { display: block; }
.brand small { opacity: .62; margin-top: 2px; }

.sidebar-nav { padding: 14px 10px; }

.sidebar-nav a {
    display: block;
    padding: 12px 14px;
    margin: 4px 0;
    border-radius: 9px;
    color: rgba(255,255,255,.8);
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: white;
    background: var(--sidebar-hover);
}

.main { margin-left: 260px; min-height: 100vh; }

.topbar {
    height: 84px;
    padding: 14px 26px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 40;
}

.topbar h1 { font-size: 20px; margin: 0 0 4px; }
.topbar p { color: var(--muted); margin: 0; font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 16px; color: var(--muted); }

.content { padding: 26px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.page-actions {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.search-form { display: flex; gap: 8px; flex: 1; max-width: 570px; }

input, select, textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    padding: 9px 12px;
    font: inherit;
    background: white;
}

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

.btn {
    border: 0;
    border-radius: 9px;
    min-height: 40px;
    padding: 9px 15px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    font: inherit;
    white-space: nowrap;
}

.btn-sm { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-success { background: #dcfce7; color: #166534; }
.btn-secondary { background: #374151; color: white; }
.btn-light { background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; }

.alert {
    padding: 13px 15px;
    margin: 0 0 18px;
    border-radius: 10px;
    border: 1px solid transparent;
}

.alert-success { background: #ecfdf5; color: #166534; border-color: #bbf7d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }

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

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

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

tbody tr:hover { background: #f9fafb; }
tbody tr:last-child td { border-bottom: 0; }
.actions-col { width: 190px; }
.row-actions { display: flex; gap: 7px; }
.row-actions form { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 36px; }

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 600;
}
.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-muted { background: #f3f4f6; color: #4b5563; }

.form-page { max-width: 850px; margin: 0 auto; }
.form-card { padding: 26px; }
.card-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 24px;
}
.card-header h2 { margin: 0 0 5px; font-size: 20px; }
.card-header p { margin: 0; color: var(--muted); }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 650; margin-bottom: 7px; }
.form-group small { display: block; color: var(--muted); margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.input-group {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: stretch;
}
.input-group span {
    display: grid;
    place-items: center;
    padding: 0 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
}
.input-group span:first-child { border-radius: 9px 0 0 9px; border-right: 0; }
.input-group span:last-child { border-radius: 0 9px 9px 0; border-left: 0; }
.input-group input { border-radius: 0; }

.checkbox-row {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 0 20px;
}
.checkbox-row input { width: 18px; min-height: 18px; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

@media (max-width: 900px) {
    .sidebar { position: static; width: 100%; }
    .main { margin-left: 0; }
    .topbar { position: static; }
    .page-actions, .topbar { align-items: stretch; flex-direction: column; height: auto; }
    .form-grid { grid-template-columns: 1fr; }
}
