:root {
    --primary: #1f6f54;
    --primary-dark: #17543f;
    --bg: #f5f6f8;
    --card-bg: #ffffff;
    --border: #e1e4e8;
    --text: #1f2328;
    --text-muted: #6b7280;
    --danger: #c0392b;
    --success: #1f6f54;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary-dark);
    color: white;
    padding: 0.75rem 1.5rem;
}
.topbar .brand { font-weight: 700; font-size: 1.2rem; }
.topbar nav a {
    color: #e6f2ee;
    text-decoration: none;
    margin-right: 1.25rem;
    font-size: 0.92rem;
}
.topbar nav a:hover { text-decoration: underline; }
.user-menu { font-size: 0.85rem; display: flex; gap: 1rem; align-items: center; }
.user-menu a { color: white; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.15rem; margin-top: 0; }

.auth-card {
    max-width: 380px;
    margin: 4rem auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
}
.auth-card .subtitle { color: var(--text-muted); margin-top: -0.5rem; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 1.5rem;
}
@media (max-width: 800px) {
    .grid-2 { grid-template-columns: 1fr; }
}

.card-form {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

label { font-size: 0.85rem; font-weight: 600; margin-top: 0.85rem; margin-bottom: 0.25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], select {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
}
.checkbox-label { flex-direction: row; align-items: center; display: flex; gap: 0.5rem; font-weight: 500; }

fieldset.permission-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
}
fieldset.permission-group legend { font-weight: 600; font-size: 0.85rem; text-transform: capitalize; }
fieldset.permission-group .checkbox-label { margin-top: 0.4rem; font-weight: 400; font-size: 0.9rem; }

button, .btn-secondary {
    margin-top: 1.25rem;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    border: none;
    background: var(--primary);
    color: white;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}
button:hover, .btn-secondary:hover { background: var(--primary-dark); }
.btn-secondary { background: #9aa1a9; margin-left: 0.5rem; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.data-table th { background: #fafbfc; font-weight: 600; }

.badge-success { background: #e5f4ee; color: var(--success); padding: 0.15rem 0.5rem; border-radius: 20px; font-size: 0.78rem; }
.badge-muted { background: #eee; color: var(--text-muted); padding: 0.15rem 0.5rem; border-radius: 20px; font-size: 0.78rem; }

.stat-grid { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem 1.75rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--text-muted); font-size: 0.85rem; }

.alert { padding: 0.7rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: #e5f4ee; color: var(--primary-dark); }
.alert-error { background: #fbe9e7; color: var(--danger); }

.pagination { margin-top: 1rem; display: flex; gap: 1rem; align-items: center; font-size: 0.9rem; }
.inline-form { margin-bottom: 1rem; display: flex; gap: 0.5rem; }

/* Permission matrix */
.subtitle { color: var(--text-muted); margin-top: -0.5rem; font-size: 0.9rem; }
.matrix-wrapper { overflow-x: auto; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; }
.matrix-table { min-width: 100%; }
.matrix-table th, .matrix-table td { white-space: nowrap; }
.matrix-module-col { position: sticky; left: 0; background: #fafbfc; min-width: 220px; z-index: 2; }
.matrix-role-col { text-align: center; min-width: 100px; }
.matrix-perm-label { position: sticky; left: 0; background: var(--card-bg); white-space: normal; max-width: 260px; z-index: 1; }
.matrix-perm-label small { color: var(--text-muted); }
.matrix-checkbox-cell { text-align: center; }
.matrix-checkbox-cell input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }
.matrix-module-row td {
    background: #eef2f0;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--primary-dark);
    position: sticky;
    left: 0;
}

/* Menu module */
.section-spacer { margin-top: 2rem; }
.inline-fields { display: flex; gap: 0.5rem; }
.inline-fields input { flex: 1; }
.chip-checklist {
    display: flex; flex-wrap: wrap; gap: 0.5rem 1rem;
    border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem;
    margin-top: 0.25rem;
}
.chip-checklist .checkbox-label { margin-top: 0; font-weight: 400; font-size: 0.9rem; }
.link-btn {
    background: none; border: none; color: var(--danger);
    padding: 0; margin: 0; font: inherit; cursor: pointer; text-decoration: underline;
}
.data-table tfoot td { font-size: 0.85rem; background: #fafbfc; }
.row-voided { opacity: 0.5; text-decoration: line-through; }
.action-row { display: flex; gap: 0.75rem; align-items: center; }
.action-row form { margin: 0; }

/* KDS */
.kds-board { display: flex; gap: 1rem; align-items: flex-start; }
.kds-column { flex: 1; background: #eef1f0; border-radius: 10px; padding: 0.75rem; min-height: 200px; }
.kds-column h2 { font-size: 1rem; margin-top: 0; }
.kds-ticket {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 0.75rem; margin-bottom: 0.75rem; border-left: 4px solid var(--primary);
}
.kds-ticket.kds-warn { border-left-color: #d9a441; }
.kds-ticket.kds-urgent { border-left-color: var(--danger); }
.kds-ticket-header { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.kds-ticket-item { font-weight: 600; margin-bottom: 0.4rem; }
.kds-ticket-timer { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.kds-ticket button { margin-top: 0; width: 100%; }
.kds-empty { color: var(--text-muted); font-size: 0.85rem; }

/* Floor plan */
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 0.25rem 0 0.75rem; vertical-align: middle; }
.legend-available { background: #6fbf8b; }
.legend-occupied { background: #c0392b; }
.legend-reserved { background: #d9a441; }
.legend-cleaning { background: #9aa1a9; }

.floor-plan {
    position: relative;
    width: 100%;
    height: 500px;
    background: #eef1f0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.floor-table {
    position: absolute;
    width: 110px;
    background: var(--card-bg);
    border: 2px solid #6fbf8b;
    border-radius: 8px;
    padding: 0.5rem;
    text-align: center;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.floor-table.shape-round { border-radius: 50%; }
.floor-table.status-occupied { border-color: var(--danger); }
.floor-table.status-reserved { border-color: #d9a441; }
.floor-table.status-cleaning { border-color: #9aa1a9; }
.floor-table-number { font-weight: 700; }
.floor-table-cap { font-size: 0.75rem; color: var(--text-muted); }
.floor-table-link { display: block; font-size: 0.75rem; margin-top: 0.25rem; }
.floor-table-qr { margin-top: 0.25rem; }
.floor-table-qr summary { font-size: 0.7rem; cursor: pointer; color: var(--text-muted); }
