/* ===========================
   CSS Design System — Nomor Surat Generator
   Tema: Office Clean (light, profesional, minim dekorasi)
   =========================== */

/* --- CSS Variables / Tokens --- */
:root {
    /* Colors — Light (monochrome) */
    --bg-page: #f2f2f2;
    --bg-secondary: #f7f7f7;
    --bg-card: #ffffff;
    --bg-card-hover: #ffffff;
    --bg-input: #ffffff;
    --bg-input-focus: #ffffff;

    --border-color: #e0e0e0;
    --border-color-hover: #bfbfbf;
    --border-color-focus: #1a1a1a;

    --text-primary: #141414;
    --text-secondary: #5a5a5a;
    --text-muted: #909090;

    --accent-primary: #1a1a1a;
    --accent-primary-hover: #000000;
    --accent-gradient: var(--accent-primary);
    --accent-glow: rgba(20, 20, 20, 0.08);
    --accent-bg: #ececec;
    --accent-on: #ffffff;

    --purple: #3a3a3a;
    --purple-bg: #ececec;
    --teal: #3a3a3a;
    --teal-bg: #ececec;
    --amber: #6b5a1e;
    --amber-bg: #f3efe1;
    --red: #8a1f1f;
    --red-hover: #6e1919;
    --red-bg: #f5e6e6;
    --red-border: #e0c2c2;
    --red-border-hover: #cf9e9e;
    --green: #1f5c33;
    --green-bg: #e6efe9;
    --green-border: #bcd8c6;
    --amber-border: #e3d5ab;
    --row-stripe: #f9f9f9;
    --scrollbar-thumb: #c9c9c9;
    --scrollbar-thumb-hover: #a3a3a3;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-card: 0 1px 2px rgba(20, 20, 20, 0.05), 0 1px 3px rgba(20, 20, 20, 0.06);
    --shadow-card-hover: 0 4px 12px rgba(20, 20, 20, 0.08);
    --shadow-glow: 0 4px 12px rgba(20, 20, 20, 0.08);
    --shadow-btn: 0 1px 2px rgba(20, 20, 20, 0.1);

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition-base: 180ms ease;
    --transition-slow: 280ms ease;

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

/* --- Colors — Dark (monochrome) --- */
[data-theme="dark"] {
    --bg-page: #101010;
    --bg-secondary: #181818;
    --bg-card: #1a1a1a;
    --bg-card-hover: #1e1e1e;
    --bg-input: #161616;
    --bg-input-focus: #1c1c1c;

    --border-color: #2c2c2c;
    --border-color-hover: #3f3f3f;
    --border-color-focus: #e8e8e8;

    --text-primary: #f2f2f2;
    --text-secondary: #b3b3b3;
    --text-muted: #767676;

    --accent-primary: #f2f2f2;
    --accent-primary-hover: #ffffff;
    --accent-gradient: var(--accent-primary);
    --accent-glow: rgba(242, 242, 242, 0.1);
    --accent-bg: #262626;
    --accent-on: #141414;

    --purple: #cfcfcf;
    --purple-bg: #242424;
    --teal: #cfcfcf;
    --teal-bg: #242424;
    --amber: #d8c27a;
    --amber-bg: #2a2515;
    --red: #e08080;
    --red-hover: #ec9a9a;
    --red-bg: #2a1a1a;
    --red-border: #4a2a2a;
    --red-border-hover: #5c3434;
    --green: #8fd0a5;
    --green-bg: #182a1f;
    --green-border: #2c4636;
    --amber-border: #4a4023;
    --row-stripe: #161616;
    --scrollbar-thumb: #3a3a3a;
    --scrollbar-thumb-hover: #4d4d4d;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-card-hover: 0 4px 14px rgba(0, 0, 0, 0.55);
    --shadow-glow: 0 4px 14px rgba(0, 0, 0, 0.5);
    --shadow-btn: 0 1px 2px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] body {
    background-color: var(--bg-page);
}

[data-theme="dark"] .app-header {
    background: var(--bg-card);
}

[data-theme="dark"] thead th {
    background: var(--bg-secondary);
}

[data-theme="dark"] tbody tr:nth-child(even) {
    background: #171717;
}

[data-theme="dark"] .btn-icon,
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .search-box,
[data-theme="dark"] .filter-select select,
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select {
    background: var(--bg-input);
}

[data-theme="dark"] .btn-primary,
[data-theme="dark"] .logo-icon,
[data-theme="dark"] .login-icon {
    color: var(--accent-on);
}

html {
    transition: background-color var(--transition-slow);
}

body,
.glass-card,
.btn-icon,
.btn-primary,
.btn-secondary,
.form-group input,
.form-group select,
.search-box,
.filter-select select,
thead th,
tbody td,
.stat-card {
    transition: background-color var(--transition-base), border-color var(--transition-base), color var(--transition-base), box-shadow var(--transition-base);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* --- Card (flat office style) --- */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.glass-card:hover {
    border-color: var(--border-color-hover);
}

/* --- App Container --- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* --- Header --- */
.app-header {
    padding: var(--space-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    margin: 0 calc(-1 * var(--space-lg));
    padding-left: var(--space-lg);
    padding-right: var(--space-lg);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1440px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    color: var(--accent-on);
}

.logo-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.org-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-primary);
    background: var(--accent-bg);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color-hover);
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

/* --- Buttons --- */
.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    border-color: var(--border-color-hover);
    color: var(--text-primary);
}

.btn-icon.btn-danger:hover {
    background: var(--red-bg);
    border-color: var(--red-border);
    color: var(--red);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 12px var(--space-lg);
    border: 1px solid var(--accent-primary-hover);
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    color: var(--accent-on);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-btn);
}

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

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-danger-solid {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 20px;
    border: 1px solid var(--red-border);
    border-radius: var(--radius-sm);
    background: var(--red-bg);
    color: var(--red);
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-danger-solid:hover {
    background: var(--red-bg);
    border-color: var(--red-border-hover);
    color: var(--red-hover);
}

/* --- Stats Section --- */
.stats-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin: var(--space-lg) 0;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--accent-primary);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
}

.stat-card:hover {
    border-color: var(--border-color-hover);
    border-left-color: var(--accent-primary);
    box-shadow: var(--shadow-card-hover);
}

#stat-month { border-left-color: var(--purple); }
#stat-types { border-left-color: var(--teal); }
#stat-latest { border-left-color: var(--amber); }

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--accent-bg);
    color: var(--accent-primary);
    flex-shrink: 0;
}

.stat-icon-purple {
    background: var(--purple-bg);
    color: var(--purple);
}

.stat-icon-teal {
    background: var(--teal-bg);
    color: var(--teal);
}

.stat-icon-amber {
    background: var(--amber-bg);
    color: var(--amber);
}

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.1;
    color: var(--text-primary);
}

.stat-value-small {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0;
    word-break: break-all;
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

/* --- Content Grid --- */
.content-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
    align-items: start;
}

/* --- Form Section --- */
.form-section {
    padding: var(--space-lg);
    position: sticky;
    top: 82px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
    gap: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.section-header h2 svg {
    color: var(--accent-primary);
}

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group label svg {
    color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group select {
    width: 100%;
    padding: 11px var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    outline: none;
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* --- Date Input: make entire box clickable & style calendar icon --- */
.form-group input[type="date"] {
    position: relative;
    cursor: pointer;
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    cursor: pointer;
    opacity: 0;
    z-index: 1;
}

/* Visible calendar icon (custom SVG via background-image) */
.form-group input[type="date"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a5a5a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    padding-right: 40px;
}

.form-group input[type="date"]:hover {
    border-color: var(--border-color-hover);
}

.form-group input[type="date"]:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231a1a1a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
}

[data-theme="dark"] .form-group input[type="date"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b3b3b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
}

[data-theme="dark"] .form-group input[type="date"]:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f2f2f2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 40px;
    cursor: pointer;
}

.select-chevron {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* --- Preview Box --- */
.preview-box {
    margin: var(--space-lg) 0;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color-hover);
    border-radius: var(--radius-md);
    text-align: center;
    transition: all var(--transition-base);
}

.preview-box.has-value {
    border-style: solid;
    border-color: var(--border-color-hover);
    background: var(--accent-bg);
}

.preview-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
}

.preview-number {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--accent-primary-hover);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    word-break: break-all;
    transition: all var(--transition-base);
}

/* --- Table Section --- */
.table-section {
    padding: var(--space-lg);
    min-height: 400px;
}

.table-controls {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.search-box {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--border-color-focus);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    width: 160px;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.filter-select {
    min-width: 140px;
}

.filter-select select {
    width: 100%;
    padding: 8px var(--space-md);
    padding-right: 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.8rem;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
}

.filter-select select:focus {
    border-color: var(--border-color-focus);
}

.table-wrapper {
    margin-top: var(--space-md);
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 880px;
}

thead th {
    padding: 11px var(--space-md);
    text-align: left;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:nth-child(even) {
    background: var(--row-stripe);
}

tbody tr:hover {
    background: var(--accent-bg);
}

tbody td {
    padding: 11px var(--space-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    overflow-wrap: break-word;
    word-break: break-word;
}

tbody td:first-child {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
}

.cell-nomor {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-weight: 600;
    font-size: 0.78rem !important;
    color: var(--accent-primary-hover) !important;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.cell-jenis {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem !important;
    font-weight: 600;
    background: var(--accent-bg);
    color: var(--accent-primary-hover) !important;
    border: 1px solid var(--border-color-hover);
    white-space: nowrap;
}

.cell-perihal,
.cell-tujuan,
.cell-pemohon {
    line-height: 1.4;
}

.cell-clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
}

.cell-clamp-1 {
    -webkit-line-clamp: 1;
}

.cell-clamp-2 {
    -webkit-line-clamp: 2;
}

.cell-pemohon {
    font-weight: 500;
    color: var(--text-primary) !important;
}

.action-cell {
    position: relative;
    display: flex;
    justify-content: center;
}

.th-aksi {
    text-align: center !important;
    width: 52px;
}

.cell-aksi {
    width: 52px;
    max-width: 52px;
    padding-left: 4px;
    padding-right: 4px;
}

.btn-row-menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-row-menu:hover {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.row-menu-dropdown {
    display: none;
    position: absolute;
    top: 34px;
    right: 0;
    z-index: 50;
    min-width: 150px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card-hover);
    padding: 4px;
    flex-direction: column;
    gap: 2px;
}

.row-menu-dropdown.open {
    display: flex;
}

.row-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.82rem;
    text-align: left;
    cursor: pointer;
    white-space: nowrap;
}

.row-menu-item:hover {
    background: var(--bg-secondary);
}

.row-menu-item-danger {
    color: var(--red);
}

.row-menu-item-danger:hover {
    background: var(--red-bg);
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl) var(--space-lg);
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    margin-bottom: var(--space-md);
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.empty-state span {
    font-size: 0.8rem;
}

.empty-state.hidden {
    display: none;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 12px var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card-hover);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    animation: toastIn 0.3s ease forwards;
    min-width: 280px;
}

.toast.toast-success {
    border-color: var(--green-border);
}

.toast.toast-success .toast-dot {
    background: var(--green);
}

.toast.toast-error {
    border-color: var(--red-border);
}

.toast.toast-error .toast-dot {
    background: var(--red);
}

.toast.toast-info {
    border-color: var(--border-color-hover);
}

.toast.toast-info .toast-dot {
    background: var(--accent-primary);
}

.toast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.toast.removing {
    animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(24px);
    }
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(28, 36, 49, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    padding: var(--space-xl);
    text-align: center;
    max-width: 380px;
    width: 90%;
    transform: scale(0.97);
    transition: transform var(--transition-base);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--red-bg);
    color: var(--red);
    margin-bottom: var(--space-md);
}

.modal-icon.modal-icon-neutral {
    background: var(--accent-bg);
    color: var(--accent-primary-hover);
}

.modal-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.modal-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: center;
}

/* --- Animations --- */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Responsive --- */
@media (max-width: 1100px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
    .form-section {
        position: static;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 0 var(--space-md);
    }

    .app-header {
        margin: 0 calc(-1 * var(--space-md));
        padding-left: var(--space-md);
        padding-right: var(--space-md);
    }

    .stats-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .header-actions .btn-icon {
        flex: 1;
        justify-content: center;
        min-width: 100px;
    }

    .table-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box input {
        width: 100%;
    }

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

    /* --- Table -> Kartu untuk layar kecil (biar tidak terpotong) --- */
    .table-wrapper {
        overflow-x: visible;
        border: none;
        border-radius: 0;
    }

    table {
        min-width: 0;
        table-layout: auto;
    }

    table, thead, tbody {
        display: block;
        width: 100%;
    }

    thead {
        display: none;
    }

    tbody tr {
        display: block;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        margin-bottom: var(--space-sm);
        padding: var(--space-sm) var(--space-md);
        box-shadow: var(--shadow-card);
    }

    tbody tr:nth-child(even) {
        background: var(--bg-card);
    }

    tbody td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: var(--space-md);
        width: 100%;
        padding: 8px 0;
        border-bottom: 1px dashed var(--border-color);
        text-align: right;
    }

    tbody td:first-child {
        display: none;
    }

    tbody td:last-child {
        border-bottom: none;
    }

    tbody td::before {
        content: attr(data-label);
        flex-shrink: 0;
        text-align: left;
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
    }

    .cell-perihal,
    .cell-tujuan,
    .cell-pemohon {
        text-align: right;
    }

    .cell-clamp {
        display: block;
        -webkit-line-clamp: unset;
        overflow: visible;
        text-align: right;
    }

    .action-cell {
        justify-content: flex-end;
        width: 100%;
    }

    .btn-row-menu {
        width: 36px;
        height: 36px;
    }

    .btn-row-label {
        display: inline;
        font-size: 0.78rem;
        font-weight: 600;
    }
}

@media (max-width: 480px) {
    .stats-section {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: var(--space-md);
    }

    .stat-value {
        font-size: 1.3rem;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* --- Login Gate --- */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(28, 36, 49, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.35s ease;
}

.login-overlay.active {
    opacity: 1;
    visibility: visible;
}

.login-card {
    position: relative;
    padding: var(--space-xl) var(--space-xl) var(--space-lg);
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: translateY(8px);
    transition: transform 0.35s ease;
    overflow: hidden;
}

.login-overlay.active .login-card {
    transform: translateY(0);
}

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: var(--accent-primary);
    color: var(--accent-on);
    margin-bottom: var(--space-lg);
}

.login-title {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: var(--space-xl);
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.login-input-group {
    margin-bottom: var(--space-lg);
    position: relative;
}

.login-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 var(--space-md);
    transition: all var(--transition-fast);
}

.login-input-wrapper:focus-within {
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-input-wrapper.error {
    border-color: var(--red-border-hover);
    box-shadow: 0 0 0 3px rgba(194, 43, 60, 0.1);
    animation: loginShake 0.4s ease;
}

@keyframes loginShake {
    0%, 100% { transform: translateX(0); }
    25%, 75% { transform: translateX(-3px); }
    50% { transform: translateX(3px); }
}

.login-input-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: var(--space-sm);
}

.login-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.95rem;
    padding: 13px 0;
    width: 100%;
}

.login-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.login-toggle-pw {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
    flex-shrink: 0;
}

.login-toggle-pw:hover {
    color: var(--text-secondary);
}

.login-error {
    font-size: 0.8rem;
    color: var(--red);
    margin-top: var(--space-sm);
    min-height: 1.2em;
    text-align: left;
    padding-left: 2px;
}

.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.login-footer-text {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.login-overlay.exiting {
    opacity: 0;
}

@media (max-width: 480px) {
    .login-card {
        padding: var(--space-lg) var(--space-md);
    }

    .login-title {
        font-size: 1.15rem;
    }
}

/* --- Alarm: Surat Belum Ada Lampiran --- */
.row-alarm {
    background: var(--amber-bg);
}

.row-alarm:hover {
    background: var(--amber-bg);
}

.row-needs-admin {
    background: var(--amber-bg);
    border-left: 3px solid var(--amber);
}

.row-needs-admin:hover {
    background: var(--amber-bg);
}

.admin-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--amber);
    margin-right: 4px;
    vertical-align: -1px;
}

.btn-upload-lampiran {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--amber-bg);
    color: var(--amber);
    border: 1px solid var(--amber-border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.btn-upload-lampiran:hover {
    background: var(--amber-bg);
}

.cell-lampiran a {
    color: var(--accent-primary-hover);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
}

.cell-lampiran a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .row-alarm {
        border-left: 3px solid var(--amber);
    }
}

/* ===========================
   Tanda Tangan — badges, buttons, modal
   =========================== */

.ttd-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.ttd-badge-waiting {
    background: var(--amber-bg);
    color: var(--amber);
    border: 1px solid var(--amber-border);
}

.ttd-badge-done {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid var(--green-border);
}

.ttd-badge-none {
    color: var(--text-muted);
}

.btn-sign-doc {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--accent-bg);
    color: var(--accent-primary-hover);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-sign-doc:hover {
    border-color: var(--border-color-hover);
}

.cell-dokumen a,
.ttd-badge-done a {
    color: var(--accent-primary-hover);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
}

.ttd-badge-done a {
    font-size: inherit;
    color: inherit;
}

.cell-ttd {
    vertical-align: middle;
}

.cell-dokumen a:hover,
.ttd-badge-done a:hover {
    text-decoration: underline;
}

.sign-modal-card {
    max-width: 780px;
    width: 94%;
    text-align: left;
    padding: var(--space-lg);
}

.sign-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.sign-modal-header h3 {
    margin-bottom: 0;
}

.sign-modal-body {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: var(--space-lg);
}

@media (max-width: 640px) {
    .sign-modal-body {
        grid-template-columns: 1fr;
    }
}

.sign-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--space-sm);
    text-align: left;
}

.sign-preview-wrapper {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    overflow: hidden;
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sign-preview-wrapper canvas {
    max-width: 100%;
    display: block;
}

.sign-marker {
    position: absolute;
    cursor: grab;
    border: 1px dashed var(--accent-primary);
    background: rgba(255,255,255,0.75);
    touch-action: none;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.sign-marker:active {
    cursor: grabbing;
}

.sign-marker-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 10px;
    text-align: center;
    line-height: 1.2;
    pointer-events: none;
    user-select: none;
    padding: 4px;
}

.sign-marker-inner img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.sign-marker-resize {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: 2px solid var(--bg-card);
    cursor: nwse-resize;
    touch-action: none;
}

.sign-page-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sign-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: var(--space-md);
}

.sign-tab {
    flex: 1;
    padding: 8px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
}

.sign-tab.active {
    background: var(--accent-bg);
    color: var(--accent-primary-hover);
    border-color: var(--border-color-hover);
}

#sign-canvas-pad {
    width: 100%;
    height: 130px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: #fff;
    touch-action: none;
}

.sign-input-col input[type="text"] {
    width: 100%;
    margin-bottom: var(--space-sm);
}

.sign-font-preview {
    display: flex;
    gap: 8px;
    margin-bottom: var(--space-sm);
}

.sign-font-preview > div {
    flex: 1;
    text-align: center;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 22px;
    cursor: pointer;
    color: var(--text-primary);
    background: #fff;
}

.sign-font-preview > div.selected {
    border-color: var(--accent-primary);
}

.sign-upload-preview {
    margin-top: var(--space-sm);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--border-color-hover);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.75rem;
}

.sign-upload-preview img {
    height: 52px;
    object-fit: contain;
}

.sign-error {
    font-size: 0.75rem;
    color: var(--red);
    margin: 6px 0 0;
}

.stamp-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    margin-top: var(--space-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.stamp-info-row img {
    height: 22px;
    width: auto;
    max-width: 90px;
    object-fit: contain;
    background: #fff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    padding: 3px 6px;
    flex-shrink: 0;
}

.stempel-current {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    border: 1px dashed var(--border-color-hover);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.8rem;
    background: var(--bg-secondary);
}

.stempel-current img {
    max-height: 100px;
    max-width: 100%;
    object-fit: contain;
}

.sign-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: var(--space-sm) 0 0;
}

.sign-modal-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    justify-content: flex-end;
}

.employee-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.employee-row .employee-email {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.employee-row button {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 0.75rem;
}

.signer-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.signer-chip .signer-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-bg);
    color: var(--accent-primary-hover);
    font-size: 0.7rem;
    font-weight: 700;
    margin-right: 8px;
}

.signer-chip button {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 0.75rem;
}

.signer-progress-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

.signer-progress-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.signer-progress-item.done {
    color: var(--green);
}

.signer-progress-item.current {
    color: var(--amber);
    font-weight: 600;
}

.ttd-hint-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    color: var(--amber);
    cursor: help;
    vertical-align: -3px;
    margin-left: 2px;
}

.ttd-hint-icon:hover,
.ttd-hint-icon:focus {
    color: var(--accent-primary-hover);
    outline: none;
}

.identity-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 6px 12px;
}
