:root {
    --ds-color-primary: #0f766e;
    --ds-color-primary-hover: #115e59;
    --ds-color-on-primary: #ffffff;
    --ds-color-text: #17202a;
    --ds-color-text-muted: #667085;
    --ds-color-background: #f6f7f9;
    --ds-color-surface: #ffffff;
    --ds-color-surface-hover: #f2f4f7;
    --ds-color-border: #dfe3e8;
    --ds-color-danger: #b42318;
    --ds-color-danger-bg: #fff3f2;
    --ds-color-success: #067647;
    --ds-color-success-bg: #ecfdf3;
    --ds-color-info-bg: #eff8ff;
    --ap-sidebar: #18232d;
    --ap-sidebar-muted: #aebbc6;
    --ap-sidebar-active: #253743;
    --ap-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html { background: var(--ds-color-background); }

body {
    margin: 0;
    min-width: 20rem;
    font-family: Inter, "Segoe UI", Tahoma, Arial, sans-serif;
    color: var(--ds-color-text);
    background: var(--ds-color-background);
    line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
a { color: inherit; }

:focus-visible {
    outline: 3px solid rgba(15, 118, 110, 0.35);
    outline-offset: 2px;
}

.ap-shell {
    display: grid;
    grid-template-columns: 17rem minmax(0, 1fr);
    min-height: 100vh;
}

.ap-shell__sidebar {
    position: sticky;
    inset-block-start: 0;
    z-index: 30;
    height: 100vh;
    overflow-y: auto;
    color: #f8fafc;
    background: var(--ap-sidebar);
    border-inline-end: 1px solid rgba(255, 255, 255, 0.08);
}

.ap-shell__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 4rem;
    padding-inline: 1.25rem;
    border-block-end: 1px solid rgba(255, 255, 255, 0.09);
}

.ap-shell__brand a {
    color: #fff;
    font-size: 1.05rem;
    font-weight: 750;
    text-decoration: none;
}

.ap-shell__content { min-width: 0; }

.ap-topbar {
    position: sticky;
    inset-block-start: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: 4rem;
    padding-inline: clamp(1rem, 3vw, 2rem);
    background: rgba(255, 255, 255, 0.96);
    border-block-end: 1px solid var(--ds-color-border);
}

.ap-topbar__home {
    font-weight: 650;
    text-decoration: none;
}

.ap-topbar__culture {
    margin-inline-start: auto;
    padding: 0.2rem 0.55rem;
    color: var(--ds-color-text-muted);
    background: var(--ds-color-surface-hover);
    border: 1px solid var(--ds-color-border);
    border-radius: 999px;
    font-size: 0.75rem;
}

.ap-icon-button {
    display: inline-grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 0.375rem;
    cursor: pointer;
}

.ap-icon-button:hover { background: rgba(148, 163, 184, 0.16); }
.ap-topbar__menu, .ap-shell__close, .ap-shell__backdrop { display: none; }

.ap-menu-icon,
.ap-menu-icon::before,
.ap-menu-icon::after {
    display: block;
    width: 1.2rem;
    height: 2px;
    background: currentColor;
    content: "";
}
.ap-menu-icon { position: relative; }
.ap-menu-icon::before { position: absolute; inset-block-start: -0.38rem; }
.ap-menu-icon::after { position: absolute; inset-block-start: 0.38rem; }

.ap-nav {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    padding: 1.1rem 0.75rem 2rem;
}

.ap-nav__group { display: flex; flex-direction: column; gap: 0.2rem; }
.ap-nav__group-label {
    margin: 0 0 0.25rem;
    padding-inline: 0.75rem;
    color: var(--ap-sidebar-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.ap-nav__link {
    display: flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.55rem 0.75rem;
    color: #dce4ea;
    border-radius: 0.375rem;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}
.ap-nav__link:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.ap-nav__link.active { color: #fff; background: var(--ap-sidebar-active); box-shadow: inset 3px 0 var(--ds-color-primary); }
[dir="rtl"] .ap-nav__link.active { box-shadow: inset -3px 0 var(--ds-color-primary); }
.ap-nav__logout { display: flex; align-items: center; width: 100%; min-height: 2.5rem; margin-block-start: .25rem; padding: .65rem .75rem; color: #fecaca; background: transparent; border: 0; border-block-start: 1px solid rgba(255, 255, 255, .12); cursor: pointer; font-size: .9rem; font-weight: 600; text-align: start; }
.ap-nav__logout:hover { color: #fff; background: rgba(180, 35, 24, .28); }
.ap-nav__logout:disabled { opacity: .6; cursor: wait; }

.ap-shell__main {
    width: 100%;
    max-width: 96rem;
    min-width: 0;
    margin-inline: auto;
    padding: clamp(1.25rem, 3vw, 2.25rem);
}

.ap-shell__main > h1:first-child {
    margin-block: 0 1.5rem;
    font-size: clamp(1.55rem, 2vw, 2rem);
    line-height: 1.25;
}

h2 { margin-block: 2rem 1rem; font-size: 1.15rem; }

.ap-table {
    width: 100%;
    margin-block: 1rem;
    background: var(--ds-color-surface);
    border: 1px solid var(--ds-color-border);
    border-radius: 0.5rem;
    border-spacing: 0;
    border-collapse: separate;
    box-shadow: var(--ap-shadow);
}

.ap-table th,
.ap-table td {
    padding: 0.75rem 0.9rem;
    text-align: start;
    vertical-align: middle;
    border-block-end: 1px solid #eaecf0;
}

.ap-table th {
    color: #475467;
    background: #f9fafb;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}
.ap-table tr:last-child td { border-block-end: 0; }
.ap-table tbody tr:hover { background: #fafcfc; }

.ap-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: 1rem;
}
.ap-card {
    min-width: 0;
    padding: 1.1rem 1.2rem;
    background: var(--ds-color-surface);
    border: 1px solid var(--ds-color-border);
    border-radius: 0.5rem;
    box-shadow: var(--ap-shadow);
}
.ap-card p { margin: 0; color: var(--ds-color-text-muted); }
.ap-card__value { margin-block-start: 0.4rem !important; color: var(--ds-color-text) !important; font-size: 1.75rem; font-weight: 700; }
.ap-card--link { color: inherit; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease; }
.ap-card--link:hover { border-color: #a6b2ba; box-shadow: 0 4px 12px rgba(16,24,40,.08); }

.ds-field { display: flex; flex-direction: column; gap: 0.4rem; max-width: 34rem; margin-block-end: 1rem; text-align: start; }
.ds-field__label { color: #344054; font-size: 0.85rem; font-weight: 650; }
.ds-field__input {
    width: 100%;
    min-height: 2.65rem;
    padding: 0.55rem 0.75rem;
    color: var(--ds-color-text);
    background: #fff;
    border: 1px solid #cfd4dc;
    border-radius: 0.375rem;
    text-align: start;
}
.ds-field__input:hover { border-color: #98a2b3; }
.ds-field__input:focus { border-color: var(--ds-color-primary); outline: 3px solid rgba(15, 118, 110, 0.14); }

.ds-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    margin-block: 0.15rem;
    margin-inline-end: 0.35rem;
    padding: 0.5rem 1rem;
    color: #fff;
    background: var(--ds-color-primary);
    border: 1px solid transparent;
    border-radius: 0.375rem;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
}
.ds-button:hover:not(:disabled) { background: var(--ds-color-primary-hover); }
.ds-button--secondary { color: #344054; background: #fff; border-color: #cfd4dc; }
.ds-button--secondary:hover:not(:disabled) { background: #f9fafb; }
.ds-button--danger { color: #fff; background: var(--ds-color-danger); }
.ds-button--danger:hover:not(:disabled) { background: #912018; }
.ds-button:disabled { cursor: not-allowed; opacity: 0.55; }
.ds-button__spinner { width: .9rem; height: .9rem; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: ap-spin .7s linear infinite; }
@keyframes ap-spin { to { transform: rotate(360deg); } }

.ds-alert { max-width: 52rem; margin-block-end: 1rem; padding: 0.75rem 1rem; border: 1px solid transparent; border-radius: 0.375rem; }
.ds-alert p { margin: 0; }
.ds-alert--error { color: var(--ds-color-danger); background: var(--ds-color-danger-bg); border-color: #fecdca; }
.ds-alert--success { color: var(--ds-color-success); background: var(--ds-color-success-bg); border-color: #abefc6; }
.ds-alert--info { color: #175cd3; background: var(--ds-color-info-bg); border-color: #b2ddff; }

.ap-empty { padding: 1.5rem !important; color: var(--ds-color-text-muted); text-align: center !important; white-space: normal; }
.ap-badge { display: inline-flex; align-items: center; min-height: 1.5rem; padding: .15rem .5rem; color: #344054; background: #f2f4f7; border-radius: 999px; font-size: .75rem; font-weight: 650; }
.ap-badge--success { color: #067647; background: #ecfdf3; }
.ap-badge--danger { color: #b42318; background: #fff3f2; }
.ap-loading { width: min(100%, 32rem); height: .9rem; margin-block: 1rem; overflow: hidden; background: #e8ecef; border-radius: .25rem; }
.ap-loading::after { display: block; width: 45%; height: 100%; background: #cfd8dc; animation: ap-loading 1.3s ease-in-out infinite alternate; content: ""; }
@keyframes ap-loading { from { transform: translateX(-100%); } to { transform: translateX(225%); } }

.ds-confirm__backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; background: rgba(16,24,40,.58); }
.ds-confirm { width: min(100%, 28rem); padding: 1.25rem; color: var(--ds-color-text); background: #fff; border: 1px solid var(--ds-color-border); border-radius: .5rem; box-shadow: 0 20px 40px rgba(16,24,40,.18); }
.ds-confirm h2 { margin: 0; padding: 0; border: 0; font-size: 1.1rem; }
.ds-confirm p { margin-block: .65rem 1.25rem; color: var(--ds-color-text-muted); }
.ds-confirm__actions { display: flex; justify-content: flex-end; gap: .5rem; }

fieldset { max-width: 52rem; margin-block: 1rem; padding: 1rem; background: #fff; border: 1px solid var(--ds-color-border); border-radius: 0.5rem; }
fieldset label { display: block; padding-block: 0.35rem; }
input[type="checkbox"] { width: 1rem; height: 1rem; margin-inline-end: 0.45rem; accent-color: var(--ds-color-primary); }
.ap-editor { display: grid; grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr); gap: 1.25rem; align-items: start; }
.ap-editor__main, .ap-editor__aside { padding: 1.25rem; background: #fff; border: 1px solid var(--ds-color-border); border-radius: .5rem; box-shadow: var(--ap-shadow); }
.ap-editor textarea { width: 100%; min-height: 20rem; resize: vertical; }
.ap-editor__aside .ds-field { max-width: none; }
.ap-editor__actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-block-start: 1rem; padding-block-start: 1rem; border-block-start: 1px solid var(--ds-color-border); }
.ap-editor__summary { min-height: 7rem !important; resize: vertical; }
.ap-filter { display: flex; align-items: end; flex-wrap: wrap; gap: .75rem; margin-block: 1rem; }
.ap-filter .ds-field { width: min(100%, 22rem); margin: 0; }
.ap-filter--wide .ds-field { width: min(100%, 17rem); }
.ap-pagination { display: flex; align-items: center; gap: .75rem; margin-block-start: 1rem; }
.ap-toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.ap-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ap-toggle span { width: 2.5rem; height: 1.4rem; background: #98a2b3; border-radius: 999px; transition: background .15s ease; }
.ap-toggle span::after { display: block; width: 1rem; height: 1rem; margin: .2rem; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(16,24,40,.2); transition: transform .15s ease; content: ""; }
.ap-toggle input:checked + span { background: var(--ds-color-primary); }
.ap-toggle input:checked + span::after { transform: translateX(1.1rem); }
[dir="rtl"] .ap-toggle input:checked + span::after { transform: translateX(-1.1rem); }
.ap-toggle input:focus-visible + span { outline: 3px solid rgba(15,118,110,.25); outline-offset: 2px; }
.app-route-state, .app-error { max-width: 42rem; padding: 1.25rem; background: #fff; border: 1px solid var(--ds-color-border); border-radius: .5rem; }

@media (max-width: 62rem) {
    .ap-shell { display: block; }
    .ap-shell__sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        width: min(18rem, 86vw);
        height: 100dvh;
        transform: translateX(-105%);
        transition: transform 180ms ease;
    }
    [dir="rtl"] .ap-shell__sidebar { transform: translateX(105%); }
    .ap-shell--nav-open .ap-shell__sidebar { transform: translateX(0); }
    .ap-shell__close, .ap-topbar__menu { display: inline-grid; }
    .ap-shell__backdrop {
        position: fixed;
        inset: 0;
        z-index: 25;
        width: 100%;
        height: 100%;
        padding: 0;
        background: rgba(16, 24, 40, 0.52);
        border: 0;
    }
    .ap-shell--nav-open .ap-shell__backdrop { display: block; }
    .ap-shell__main { overflow-x: hidden; }
    .ap-editor { grid-template-columns: 1fr; }
}

@media (max-width: 44rem) {
    .ap-shell__main { padding: 1rem; }
    .ap-table { display: block; overflow-x: auto; white-space: nowrap; }
    .ap-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ds-field { max-width: none; }
}

@media (max-width: 27rem) { .ap-cards { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
