/* ========== Base ========== */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f9fbfd;
    --border: #d9e1ea;
    --text: #1f2a37;
    --text-soft: #5b6777;
    --heading: #0f1720;

    --primary: #1e4fa3;
    --primary-hover: #163d7f;
    --primary-soft: #eaf1fb;

    --success: #1f7a3f;
    --success-bg: #edf8f0;

    --warning: #a15c00;
    --warning-bg: #fff6e8;

    --danger: #a12828;
    --danger-hover: #821f1f;
    --danger-bg: #fff1f1;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --container: 1200px;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

/* ========== Layout ========== */
.page {
    max-width: var(--container);
    margin: 0 auto;
    padding: 32px 24px 48px;
}

.page-header {
    margin-bottom: 24px;
}

.page-title {
    margin: 0 0 8px;
    color: var(--heading);
    font-size: 2rem;
    font-weight: 700;
}

.page-subtitle {
    margin: 0;
    color: var(--text-soft);
    font-size: 1rem;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.card-tight {
    padding: 16px 18px;
}

/* ========== Tree View ========== */

.tree-node {
    margin-left: 6px;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.tree-row:hover {
    background: var(--surface-soft);
}

.tree-toggle {
    width: 14px;
    font-size: 0.8rem;
    color: var(--text-soft);
}

.tree-name {
    font-weight: 600;
    color: var(--text);
}

.tree-children {
    display: none;
    margin-left: 18px;
    border-left: 1px dashed var(--border);
    padding-left: 10px;
}



/* ========== Buttons ========== */
.btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 10px;
    border: 1px solid #b8cef0;
    background: #eaf1fb;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
    background: #dceaf8;
    border-color: #6a9fd8;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
}

.btn-danger {
    background: #ffffff;
    border-color: #d9a4a4;
    color: var(--danger);
}

.btn-danger:hover {
    background: #fff5f5;
    border-color: var(--danger);
    color: var(--danger-hover);
}

.btn-dark {
    background: var(--heading, #0f1720);
    border-color: var(--heading, #0f1720);
    color: #ffffff;
}

.btn-dark:hover {
    background: #1f2a37;
    border-color: #1f2a37;
    color: #ffffff;
    text-decoration: none;
}

.btn + .btn {
    margin-left: 8px;
}

/* ========== Messages ========== */
.alert {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.95rem;
}

.alert-success {
    background: var(--success-bg);
    border-color: #b9dfc4;
    color: var(--success);
}

.alert-warning {
    background: var(--warning-bg);
    border-color: #f0d29a;
    color: var(--warning);
}

.alert-danger {
    background: var(--danger-bg);
    border-color: #e4b4b4;
    color: var(--danger);
}

/* ========== Forms ========== */
.form-card {
    max-width: 760px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--heading);
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    font-size: 0.95rem;
}

/* Select fix */
select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background-color: #ffffff;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;

    /* remove native styling */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    /* custom dropdown arrow */
    background-image: url("data:image/svg+xml;utf8,<svg fill='%231f2a37' height='20' viewBox='0 0 20 20' width='20' xmlns='http://www.w3.org/2000/svg'><path d='M5.5 7.5l4.5 5 4.5-5'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-left: 12px;   /* match input exactly */
    text-indent: 5px;     /* subtle shift to match rendering */
    padding-right: 36px;
}

select:focus {
    outline: none;
    border-color: #9ab4dc;
    box-shadow: 0 0 0 3px rgba(30, 79, 163, 0.10);
}

input,
select {
    height: 42px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: #9ab4dc;
    box-shadow: 0 0 0 3px rgba(30, 79, 163, 0.10);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-actions {
    margin-top: 8px;
}

/* ========== Tables ========== */
.table-card {
    overflow: hidden;
    padding: 0;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.table th,
.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
    font-size: 0.95rem;
}

.table th {
    background: var(--surface-soft);
    color: var(--heading);
    font-weight: 700;
}

.table tr:hover td {
    background: #fafcff;
}

.table .actions {
    white-space: nowrap;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.badge-active {
    background: #edf8f0;
    color: var(--success);
}

.badge-inactive {
    background: #f1f3f6;
    color: #5f6b7a;
}

/* ========== Utility ========== */
.text-soft {
    color: var(--text-soft);
}

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .page {
        padding: 20px 14px 32px;
    }

    .page-title {
        font-size: 1.6rem;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    .btn + .btn {
        margin-left: 0;
        margin-top: 8px;
    }

    .row {
        align-items: stretch;
    }
}