/* ============================================================
   Parchival — Design System
   assets/css/app.css
   
   Palette:
     Slate   #1e3a3a  (primary / sidebar)
     Teal    #0f5252  (hover states)
     Amber   #c8841a  (accent / links)
     Surface #f7f5f0  (page background)
     Card    #ffffff
     Border  #e2ddd6
     Text    #1a1a18  (primary)
     Muted   #6b6860  (secondary)
   ============================================================ */

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: #1a1a18;
    background: #f7f5f0;
    min-height: 100vh;
}

a { color: #c8841a; text-decoration: none; }
a:hover { color: #a06a12; text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ── Typography ───────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: #1a1a18;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

code, pre {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: .875rem;
    background: #eeebe4;
    border-radius: 4px;
}
code { padding: 1px 5px; }
pre { padding: 1rem; overflow-x: auto; }

/* ── App shell ────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #1e3a3a;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
}

.sidebar-logo-icon {
    width: 32px;
    height: 32px;
    background: #c8841a;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-icon svg {
    width: 18px;
    height: 18px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-logo-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.01em;
}

.sidebar-logo-sub {
    font-size: .7rem;
    color: rgba(255,255,255,.45);
    font-weight: 400;
    display: block;
    margin-top: -2px;
}

.sidebar-section {
    padding: 16px 0 8px;
}

.sidebar-section-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: rgba(255,255,255,.35);
    padding: 0 20px;
    margin-bottom: 4px;
}

.sidebar-nav { list-style: none; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 20px;
    font-size: .9rem;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
    text-decoration: none;
}

.sidebar-nav a.active {
    background: rgba(200,132,26,.15);
    color: #f5b84a;
    border-left-color: #c8841a;
}

.sidebar-nav a .ti {
    font-size: 17px;
    flex-shrink: 0;
    opacity: .8;
}

.sidebar-nav a.active .ti { opacity: 1; }

.sidebar-footer {
    margin-top: auto;
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Main content area ────────────────────────────────────── */
.main-wrap {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
    background: #fff;
    border-bottom: 1px solid #e2ddd6;
    padding: 0 28px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a18;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .875rem;
    color: #6b6860;
}

.topbar-user strong { color: #1a1a18; font-weight: 500; }

.topbar-avatar {
    width: 30px;
    height: 30px;
    background: #1e3a3a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* ── Page content ─────────────────────────────────────────── */
.page-content {
    padding: 28px;
    flex: 1;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.page-header-left h1 { font-size: 1.4rem; }
.page-header-left p  { color: #6b6860; font-size: .9rem; margin-top: 3px; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: #fff;
    border: 1px solid #e2ddd6;
    border-radius: 10px;
    padding: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0ece5;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a18;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .ti { color: #c8841a; font-size: 18px; }

/* ── Stat cards ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e2ddd6;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stat-card-icon--teal    { background: #e0f2ee; color: #0f5252; }
.stat-card-icon--amber   { background: #fdf0d8; color: #a06a12; }
.stat-card-icon--slate   { background: #e8efef; color: #1e3a3a; }
.stat-card-icon--red     { background: #fde8e8; color: #991b1b; }

.stat-card-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1a1a18;
    line-height: 1;
}

.stat-card-label {
    font-size: .8rem;
    color: #6b6860;
}

/* ── Grid layouts ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #e2ddd6;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

thead th {
    background: #f7f5f0;
    padding: 10px 16px;
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b6860;
    border-bottom: 1px solid #e2ddd6;
    white-space: nowrap;
}

tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid #f0ece5;
    vertical-align: middle;
    color: #1a1a18;
}

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

tbody tr:hover td { background: #faf8f4; }

.td-muted { color: #6b6860; font-size: .82rem; }
.td-mono  { font-family: 'JetBrains Mono', monospace; font-size: .8rem; color: #6b6860; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 7px;
    font-size: .875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background .15s, border-color .15s, opacity .15s;
    white-space: nowrap;
}

.btn .ti { font-size: 16px; }

.btn-primary {
    background: #1e3a3a;
    color: #fff;
    border-color: #1e3a3a;
}
.btn-primary:hover {
    background: #0f5252;
    border-color: #0f5252;
    color: #fff;
    text-decoration: none;
}

.btn-accent {
    background: #c8841a;
    color: #fff;
    border-color: #c8841a;
}
.btn-accent:hover {
    background: #a06a12;
    border-color: #a06a12;
    color: #fff;
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    color: #1e3a3a;
    border-color: #c8c4bc;
}
.btn-outline:hover {
    background: #f0ece5;
    text-decoration: none;
    color: #1e3a3a;
}

.btn-danger {
    background: #991b1b;
    color: #fff;
    border-color: #991b1b;
}
.btn-danger:hover { background: #7f1d1d; border-color: #7f1d1d; color: #fff; text-decoration: none; }

.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-sm .ti { font-size: 14px; }

.btn-icon {
    padding: 6px;
    border-radius: 6px;
    line-height: 1;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: .825rem;
    font-weight: 500;
    color: #3d3b38;
    margin-bottom: 5px;
}

.form-label .req { color: #c8841a; margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d0ccc5;
    border-radius: 7px;
    font-size: .9rem;
    font-family: inherit;
    color: #1a1a18;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: #1e3a3a;
    box-shadow: 0 0 0 3px rgba(30,58,58,.1);
}

.form-control::placeholder { color: #b0ada7; }

textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6860' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.form-hint { font-size: .78rem; color: #8a8680; margin-top: 4px; }
.form-error { font-size: .78rem; color: #991b1b; margin-top: 4px; }

.form-control.is-invalid { border-color: #dc2626; }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.1); }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-section {
    background: #faf8f4;
    border: 1px solid #ede9e2;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.form-section-title {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #8a8680;
    margin-bottom: 16px;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.badge--green  { background: #dcfce7; color: #166534; }
.badge--blue   { background: #dbeafe; color: #1e40af; }
.badge--amber  { background: #fef3c7; color: #92400e; }
.badge--red    { background: #fee2e2; color: #991b1b; }
.badge--gray   { background: #f1f0e8; color: #4b4a47; }
.badge--teal   { background: #ccfbf1; color: #0f766e; }
.badge--dark   { background: #e2e8f0; color: #334155; }

/* ── Flash messages ───────────────────────────────────────── */
.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: .875rem;
    margin-bottom: 20px;
    border-left: 3px solid;
}

.flash .ti { font-size: 17px; flex-shrink: 0; margin-top: 1px; }

.flash--success { background: #f0fdf4; border-color: #16a34a; color: #14532d; }
.flash--error   { background: #fef2f2; border-color: #dc2626; color: #7f1d1d; }
.flash--warning { background: #fffbeb; border-color: #d97706; color: #78350f; }
.flash--info    { background: #eff6ff; border-color: #2563eb; color: #1e3a8a; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border-radius: 6px;
    font-size: .825rem;
    font-weight: 500;
    color: #3d3b38;
    background: #fff;
    border: 1px solid #e2ddd6;
    text-decoration: none;
    transition: background .15s, border-color .15s;
}

.pagination__btn:hover {
    background: #f0ece5;
    text-decoration: none;
    color: #1a1a18;
}

.pagination__btn--active {
    background: #1e3a3a;
    border-color: #1e3a3a;
    color: #fff;
}

.pagination__btn--active:hover {
    background: #0f5252;
    color: #fff;
}

.pagination__btn--disabled {
    color: #c8c4bc;
    cursor: default;
    pointer-events: none;
}

.pagination__ellipsis {
    color: #8a8680;
    padding: 0 4px;
    font-size: .825rem;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #8a8680;
}

.empty-state .ti {
    font-size: 40px;
    display: block;
    margin: 0 auto 12px;
    color: #c8c4bc;
}

.empty-state h3 { color: #4b4a47; margin-bottom: 6px; }
.empty-state p  { font-size: .875rem; margin-bottom: 20px; }

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    color: #8a8680;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.breadcrumb a { color: #8a8680; text-decoration: none; }
.breadcrumb a:hover { color: #c8841a; }
.breadcrumb .sep { color: #c8c4bc; }
.breadcrumb .current { color: #3d3b38; font-weight: 500; }

/* ── Dropdown menu ────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid #e2ddd6;
    border-radius: 8px;
    min-width: 180px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    z-index: 200;
    display: none;
    overflow: hidden;
}

.dropdown-menu.show { display: block; }

.dropdown-menu a,
.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    font-size: .875rem;
    color: #1a1a18;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background .1s;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
    background: #f7f5f0;
    text-decoration: none;
}

.dropdown-menu .ti { font-size: 16px; color: #6b6860; }
.dropdown-divider { border-bottom: 1px solid #f0ece5; margin: 4px 0; }

/* ── Search bar ───────────────────────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 0;
    background: #f7f5f0;
    border: 1px solid #d0ccc5;
    border-radius: 7px;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}

.search-bar:focus-within {
    border-color: #1e3a3a;
    box-shadow: 0 0 0 3px rgba(30,58,58,.1);
    background: #fff;
}

.search-bar .ti {
    padding: 0 10px;
    color: #8a8680;
    font-size: 17px;
    flex-shrink: 0;
}

.search-bar input {
    border: none;
    background: transparent;
    padding: 8px 12px 8px 0;
    font-size: .875rem;
    font-family: inherit;
    color: #1a1a18;
    width: 100%;
}

.search-bar input:focus { outline: none; }
.search-bar input::placeholder { color: #b0ada7; }

/* ── Toolbar (above tables) ───────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.show { display: flex; }

.modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f0ece5;
}

.modal-title { font-size: 1rem; font-weight: 600; }

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #8a8680;
    font-size: 20px;
    line-height: 1;
    padding: 2px;
    border-radius: 4px;
    display: flex;
}

.modal-close:hover { color: #1a1a18; background: #f0ece5; }

.modal-body { padding: 20px 24px; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid #f0ece5;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #e2ddd6;
    margin-bottom: 20px;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: .875rem;
    font-weight: 500;
    color: #6b6860;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-family: inherit;
    transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: #1a1a18; }
.tab-btn.active { color: #1e3a3a; border-bottom-color: #1e3a3a; }
.tab-btn .ti { font-size: 16px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Login page ───────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e3a3a;
    padding: 24px;
}

.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.login-logo-icon {
    width: 40px;
    height: 40px;
    background: #1e3a3a;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo-icon svg {
    width: 22px;
    height: 22px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.login-logo-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a18;
    letter-spacing: -.02em;
}

.login-logo-name span { color: #c8841a; }

.login-heading { font-size: 1.1rem; margin-bottom: 6px; }
.login-sub { font-size: .875rem; color: #6b6860; margin-bottom: 28px; }

.login-divider {
    text-align: center;
    font-size: .75rem;
    color: #b0ada7;
    margin: 20px 0;
    position: relative;
}

.login-footer {
    text-align: center;
    font-size: .78rem;
    color: #8a8680;
    margin-top: 24px;
}

/* ── Utilities ────────────────────────────────────────────── */
.text-muted   { color: #6b6860; }
.text-sm      { font-size: .825rem; }
.text-xs      { font-size: .75rem; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.fw-500       { font-weight: 500; }
.fw-600       { font-weight: 600; }
.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrap { margin-left: 0; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .topbar { padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: .01ms !important; }
}
