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

:root {
    --forest: #1a3a2a;
    --forest-mid: #2d5a3d;
    --forest-light: #3d7a52;
    --saffron: #e8882a;
    --saffron-lt: #f5a84a;
    --cream: #faf6ef;
    --cream-dk: #f0e8d8;
    --white: #ffffff;
    --text-dark: #1a1a14;
    --text-mid: #4a4a3a;
    --text-mute: #7a7a6a;
    --danger: #c0392b;
    --success: #27ae60;
    --warning: #f39c12;
    --info: #2980b9;
    --sidebar-w: 250px;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--cream);
    color: var(--text-dark);
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--forest);
    display: flex;
    flex-direction: column;
    z-index: 100;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo {
    width: 38px; height: 38px;
    background: var(--saffron);
    color: var(--white);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}
.sidebar-title {
    color: var(--cream);
    font-weight: 600;
    font-size: 15px;
}
.sidebar-subtitle {
    color: rgba(250,246,239,0.5);
    font-size: 12px;
}
.sidebar-menu {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    color: rgba(250,246,239,0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    color: var(--cream);
}
.sidebar-link.active {
    background: rgba(232,136,42,0.15);
    color: var(--saffron-lt);
}

/* ── MAIN ── */
.main-content {
    margin-left: var(--sidebar-w);
    padding: 32px 40px;
    min-height: 100vh;
}
.page-header {
    margin-bottom: 28px;
}
.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--forest);
}
.page-header p {
    color: var(--text-mute);
    font-size: 14px;
    margin-top: 4px;
}

/* ── STAT CARDS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--cream-dk);
}
.stat-card .stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-mute);
    margin-bottom: 8px;
}
.stat-card .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--forest);
}
.stat-card .stat-sub {
    font-size: 12px;
    color: var(--text-mute);
    margin-top: 4px;
}
.stat-card.saffron .stat-value { color: var(--saffron); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.info .stat-value { color: var(--info); }

/* ── TABLES ── */
.table-wrap {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--cream-dk);
    overflow: hidden;
}
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--cream-dk);
}
.table-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--forest);
}
.table-filter {
    display: flex;
    gap: 8px;
    align-items: center;
}
.table-filter select, .table-filter input {
    padding: 7px 12px;
    border: 1px solid var(--cream-dk);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--white);
    color: var(--text-dark);
}
table {
    width: 100%;
    border-collapse: collapse;
}
table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-mute);
    background: var(--cream);
    border-bottom: 1px solid var(--cream-dk);
    font-weight: 600;
}
table td {
    padding: 14px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--cream-dk);
    color: var(--text-dark);
    vertical-align: top;
}
table tr:last-child td { border-bottom: none; }
table tr:hover { background: rgba(250,246,239,0.5); }
table td a {
    color: var(--forest);
    font-weight: 500;
    text-decoration: none;
}
table td a:hover { text-decoration: underline; }

/* ── STATUS BADGES ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-new { background: #e8f5e9; color: #2e7d32; }
.badge-in-progress { background: #fff3e0; color: #e65100; }
.badge-replied { background: #e3f2fd; color: #1565c0; }
.badge-closed { background: #f5f5f5; color: #757575; }
.badge-approved { background: #e8f5e9; color: #2e7d32; }
.badge-rejected { background: #fce4ec; color: #c62828; }

/* ── DETAIL PAGE ── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 24px;
}
.detail-card {
    background: var(--white);
    border-radius: 12px;
    border: 1px solid var(--cream-dk);
    padding: 24px;
}
.detail-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--forest);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--cream-dk);
}
.detail-row {
    display: flex;
    padding: 8px 0;
    gap: 12px;
}
.detail-label {
    width: 140px;
    flex-shrink: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-mute);
    padding-top: 2px;
}
.detail-value {
    font-size: 14px;
    color: var(--text-dark);
    word-break: break-word;
}
.detail-message {
    margin-top: 16px;
    padding: 16px;
    background: var(--cream);
    border-left: 3px solid var(--saffron);
    border-radius: 0 8px 8px 0;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-wrap;
}

/* ── STATUS + REMARKS PANEL ── */
.status-form {
    margin-bottom: 20px;
}
.status-form label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-mute);
    margin-bottom: 6px;
}
.status-form select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--cream-dk);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: var(--white);
    cursor: pointer;
}
.remark-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}
.remark-item {
    padding: 12px;
    background: var(--cream);
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}
.remark-meta {
    font-size: 11px;
    color: var(--text-mute);
    margin-top: 6px;
}
.remark-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--cream-dk);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 70px;
    margin-bottom: 8px;
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn-primary {
    background: var(--forest);
    color: var(--white);
}
.btn-primary:hover { background: var(--forest-mid); }
.btn-saffron {
    background: var(--saffron);
    color: var(--white);
}
.btn-saffron:hover { background: #d47a22; }
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--cream-dk);
    color: var(--text-mid);
}
.btn-outline:hover {
    border-color: var(--forest);
    color: var(--forest);
}
.btn-block { width: 100%; }

/* ── LOGIN ── */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--forest);
}
.login-card {
    width: 400px;
    background: var(--white);
    border-radius: 16px;
    padding: 40px;
}
.login-card h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--forest);
    margin-bottom: 6px;
}
.login-card p {
    color: var(--text-mute);
    font-size: 14px;
    margin-bottom: 28px;
}
.form-group {
    margin-bottom: 18px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-mid);
    margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--cream-dk);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--forest-mid);
}

/* ── ALERTS ── */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
}
.alert-error {
    background: #fce4ec;
    color: #c62828;
    border: 1px solid #f8bbd0;
}
.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

/* ── PAGINATION ── */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 16px;
}
.pagination a, .pagination span {
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text-mid);
    border: 1px solid var(--cream-dk);
}
.pagination a:hover {
    background: var(--cream);
}
.pagination .current {
    background: var(--forest);
    color: var(--white);
    border-color: var(--forest);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-mute);
    text-decoration: none;
    font-size: 13px;
    margin-bottom: 16px;
}
.back-link:hover { color: var(--forest); }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-mute);
}
.empty-state p { font-size: 15px; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
    .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-brand > div, .sidebar-link span, .sidebar-title, .sidebar-subtitle { display: none; }
    .sidebar-link { justify-content: center; padding: 12px; }
    .sidebar-brand { justify-content: center; padding: 16px; }
    .main-content { margin-left: 60px; padding: 20px; }
}
