/* =====================================================================
   Politici Mediu — sistem de design
   Paletă: verde pin / hârtie caldă · Fonturi: Space Grotesk + IBM Plex Sans
   ===================================================================== */

:root {
    --bg:            #F4F5F0;
    --surface:       #FFFFFF;
    --ink:           #16241C;
    --muted:         #667469;
    --line:          #E2E5DC;
    --brand:         #1E4D3A;
    --brand-strong:  #163B2C;
    --brand-soft:    #E8F0EA;
    --accent:        #C08A2D;
    --danger:        #B23B3B;
    --danger-soft:   #F6E7E5;
    --ok:            #2F6F4F;
    --ok-soft:       #E4F0E7;

    --radius:        14px;
    --radius-sm:     10px;
    --shadow:        0 1px 2px rgba(22,36,28,.05), 0 8px 24px rgba(22,36,28,.06);
    --shadow-sm:     0 1px 2px rgba(22,36,28,.06);

    --font-display:  'Space Grotesk', system-ui, sans-serif;
    --font-body:     'IBM Plex Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
    letter-spacing: -0.01em;
}

a { color: var(--brand); }

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--brand-soft);
    padding: 1px 6px;
    border-radius: 6px;
    font-size: .9em;
}

.muted { color: var(--muted); }
.small { font-size: .86rem; }

/* --------------------------- Layout --------------------------- */
.container {
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 0 24px;
}

main.container { padding-top: 32px; padding-bottom: 64px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}
.page-head h2 { font-size: 1.6rem; }
.page-head p { margin: 4px 0 0; }

/* --------------------------- Topbar --------------------------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-inner {
    max-width: 1040px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    text-decoration: none;
    color: var(--ink);
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--brand);
    color: #fff;
    flex: none;
}
.brand-mark-lg {
    width: 52px;
    height: 52px;
    border-radius: 15px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--font-display); font-size: 1.02rem; font-weight: 600; }
.brand-text small { color: var(--muted); font-size: .76rem; }

.mainnav {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}
.mainnav a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 500;
    font-size: .94rem;
    padding: 8px 14px;
    border-radius: 9px;
    transition: background .15s, color .15s;
}
.mainnav a:hover { background: var(--bg); color: var(--ink); }
.mainnav a.is-active { background: var(--brand-soft); color: var(--brand-strong); }

.userbox {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-name { font-weight: 500; font-size: .92rem; }

.badge {
    font-size: .72rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 100px;
    letter-spacing: .01em;
}
.badge-admin { background: var(--brand); color: #fff; }
.badge-sub { background: var(--brand-soft); color: var(--brand-strong); }

.tag {
    display: inline-block;
    font-size: .68rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--accent);
    color: #fff;
    margin-left: 6px;
    vertical-align: middle;
}

/* --------------------------- Buttons --------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: .94rem;
    font-weight: 600;
    line-height: 1;
    padding: 11px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); }

.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9c3232; }

.btn-sm { padding: 7px 12px; font-size: .85rem; border-radius: 8px; }
.btn-block { width: 100%; }

/* --------------------------- Alerts --------------------------- */
.alert {
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 20px;
    font-size: .94rem;
    border: 1px solid transparent;
}
.alert p { margin: 6px 0 0; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #cfe6d6; }
.alert-error { background: var(--danger-soft); color: #8f2f2f; border-color: #ecccc8; }
.alert-error div + div { margin-top: 4px; }

/* --------------------------- Forms --------------------------- */
.form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: .84rem; font-weight: 500; color: var(--muted); }

.field input,
.field select {
    font-family: var(--font-body);
    font-size: .96rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 13px;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(30,77,58,.12);
}

.form-inline {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 18px;
    align-items: end;
}
.form-inline .field-narrow { max-width: 140px; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 10px; }

/* --------------------------- Panel --------------------------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    margin-bottom: 26px;
}
.panel h3 { font-size: 1.12rem; margin-bottom: 16px; }

.manage-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 26px;
}
.manage-block h4 { font-size: .98rem; margin-bottom: 12px; }
.manage-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

/* --------------------------- Cards grid --------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
    gap: 18px;
}

.app-card {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 18px 18px 0;
    text-decoration: none;
    color: var(--ink);
    overflow: hidden;
    transition: box-shadow .18s, transform .12s, border-color .18s;
}
.app-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    border-color: #d4dccf;
}
.app-card-bar {
    width: 5px;
    flex: none;
    background: var(--brand);
    border-radius: 0 4px 4px 0;
}
.app-card:hover .app-card-bar { background: var(--accent); }

.app-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; padding-left: 4px; }
.app-card-title { font-family: var(--font-display); font-weight: 600; font-size: 1.04rem; }
.app-card-desc { color: var(--muted); font-size: .9rem; }
.app-card-url {
    color: var(--muted);
    font-size: .78rem;
    margin-top: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.app-card-arrow {
    align-self: center;
    color: var(--muted);
    margin-right: 4px;
    flex: none;
    transition: color .18s, transform .18s;
}
.app-card:hover .app-card-arrow { color: var(--brand); transform: translate(2px, -2px); }

/* --------------------------- Table --------------------------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    text-align: left;
    padding: 14px 18px;
    vertical-align: middle;
}
.table thead th {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 600;
    background: #FafBf8;
    border-bottom: 1px solid var(--line);
}
.table tbody tr + tr td { border-top: 1px solid var(--line); }
.table tbody tr:hover td { background: #FBFCFA; }
.cell-url {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .82rem;
    color: var(--muted);
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.col-num { width: 88px; text-align: center; }
td.col-num { text-align: center; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }
.col-actions .btn { margin-left: 6px; }
.inline { display: inline; }

/* --------------------------- Empty state --------------------------- */
.empty {
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    padding: 52px 24px;
}
.empty h3 { font-size: 1.16rem; margin-bottom: 8px; }
.empty p { color: var(--muted); margin: 0 0 18px; }

/* --------------------------- Footer --------------------------- */
.sitefooter {
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .84rem;
    padding: 22px 0;
}

/* --------------------------- Auth pages --------------------------- */
body.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(160deg, #F4F5F0 0%, #EAF0EA 100%);
}
.auth-bg {
    position: absolute;
    inset: 0;
    color: var(--brand);
    opacity: .10;
    pointer-events: none;
}
.auth-bg svg { width: 100%; height: 100%; }

.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 396px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 34px 30px;
}
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .brand-mark { margin: 0 auto 14px; }
.auth-head h1 { font-size: 1.5rem; margin-bottom: 4px; }
.auth-head p { margin: 0; }
.auth-intro { text-align: center; margin: -8px 0 20px; }
.auth-card .alert { text-align: left; }
.auth-card .form { margin-top: 4px; }

/* --------------------------- Responsive --------------------------- */
@media (max-width: 860px) {
    .form-inline { grid-template-columns: 1fr; }
    .form-inline .field-narrow { max-width: none; }
    .manage-grid { grid-template-columns: 1fr; gap: 20px; }
    .mainnav { margin-left: 0; }
}

@media (max-width: 620px) {
    .topbar-inner { gap: 12px; height: auto; padding: 12px 16px; flex-wrap: wrap; }
    .brand-text small { display: none; }
    .mainnav { order: 3; width: 100%; }
    .userbox { gap: 8px; }
    .user-name { display: none; }
    .container, .topbar-inner { padding-left: 16px; padding-right: 16px; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .cell-url { max-width: 140px; }
    .col-actions .btn { margin-left: 4px; }
}

/* --------------------------- A11y --------------------------- */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
    .app-card:hover { transform: none; }
}
