:root {
    --fg: #1a1a1a;
    --muted: #666;
    --accent: #2d6cdf;
    --border: #ddd;
    --bg: #fafafa;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
}

main {
    max-width: 34rem;
    margin: 4rem auto;
    padding: 0 1.25rem;
}

h1 {
    margin: 0 0 .25rem;
    font-size: 2rem;
    letter-spacing: -.02em;
}

.sub {
    margin: 0 0 2rem;
    color: var(--muted);
}

form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .9rem;
    color: var(--muted);
}

input {
    padding: .6rem .75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--fg);
}

input:focus {
    outline: none;
    border-color: var(--accent);
}

button {
    align-self: flex-start;
    padding: .6rem 1.25rem;
    font-size: 1rem;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

button:hover { filter: brightness(1.05); }

.box {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    word-break: break-all;
}

.box.ok  { background: #eaf3ea; border: 1px solid #bcdcbc; }
.box.err { background: #fbeaea; border: 1px solid #e3bcbc; }

.box p { margin: 0 0 .35rem; }

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

.nav { margin-top: 2rem; font-size: .9rem; }

.topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.logout {
    font-size: .85rem;
    padding: .35rem .8rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--muted);
    white-space: nowrap;
}

.logout:hover { border-color: var(--accent); color: var(--accent); }

main.wide { max-width: min(96vw, 96rem); }

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

th, td {
    text-align: left;
    padding: .6rem .5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th { color: var(--muted); font-weight: 600; }

td.target {
    max-width: 24rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

td.date { color: var(--muted); white-space: nowrap; }

.tablewrap { overflow-x: auto; }

table td, table th { white-space: nowrap; }

td.icons {
    display: flex;
    gap: .3rem;
    align-items: center;
}

/* Einzelne Icon-Spalten: schmal, Icon zentriert. */
td.ic-cell {
    width: 1%;
    text-align: center;
    padding: .4rem .3rem;
}

td.cb { width: 1%; }

/* Status-Zelle: Uhr-Icon (Ablauf ändern) vor dem Status-Badge. */
td.status {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* Aufrufe-Zahl als klickbarer Link (öffnet das Log-Popup). */
.usagebtn {
    background: none;
    border: 0;
    padding: 0;
    color: var(--muted);
    font-size: .82rem;
    cursor: pointer;
    text-decoration: underline dotted;
}

.usagebtn:hover { color: var(--accent); }

/* Icon-Buttons: gleiche Größe, SVG als Hintergrund (keine externen Ressourcen). */
.ic {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: #fff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
    cursor: pointer;
    flex: 0 0 auto;
}

.ic:hover { border-color: var(--accent); }

.ic.copy  { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232d6cdf' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='11' height='11' rx='2'/%3E%3Cpath d='M5 15V5a2 2 0 0 1 2-2h10'/%3E%3C/svg%3E"); }
.ic.deact { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%23b56a00'%3E%3Crect x='6' y='5' width='4' height='14' rx='1'/%3E%3Crect x='14' y='5' width='4' height='14' rx='1'/%3E%3C/svg%3E"); }
.ic.react { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%232b7a2b'%3E%3Cpath d='M7 5l12 7-12 7z'/%3E%3C/svg%3E"); }
.ic.del   { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23bb2233' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16'/%3E%3Cpath d='M9 7V4h6v3'/%3E%3Cpath d='M6 7l1 13h10l1-13'/%3E%3C/svg%3E"); }
.ic.edit  { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.ic.stats { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232d6cdf' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='6' y1='20' x2='6' y2='12'/%3E%3Cline x1='12' y1='20' x2='12' y2='6'/%3E%3Cline x1='18' y1='20' x2='18' y2='14'/%3E%3C/svg%3E"); }

td.empty { color: var(--muted); text-align: center; padding: 2rem; }

.bulkbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
    padding: .6rem .8rem;
    background: #f0f2f5;
    border-radius: 6px;
    font-size: .85rem;
}

.bulkbar select, .expedit select, .expedit input {
    padding: .3rem .4rem;
    font-size: .8rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: #fff;
}

.bulkbar button { padding: .35rem .8rem; font-size: .8rem; }

/* Ablauf-Popup */
.expdlg {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    width: min(22rem, 92vw);
    box-shadow: 0 10px 40px rgba(0, 0, 0, .18);
}

.expdlg::backdrop { background: rgba(0, 0, 0, .35); }

.expdlg .dlg-t { margin: 0 0 1rem; font-size: 1rem; }

.expdlg label {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin-bottom: .9rem;
    font-size: .85rem;
    color: var(--muted);
}

.expdlg select, .expdlg input {
    padding: .45rem .5rem;
    font-size: .9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

.dlg-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: .5rem;
}

.dlg-actions button { padding: .45rem 1rem; font-size: .85rem; }

button.ghost { background: #eee; color: var(--fg); }

td.usage { color: var(--muted); font-size: .82rem; }
.muted { color: #aaa; }

.loglist {
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
    max-height: 16rem;
    overflow-y: auto;
    font-size: .85rem;
}

.loglist li {
    padding: .3rem 0;
    border-bottom: 1px solid #f0f0f0;
    color: var(--fg);
}

.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .78rem;
    white-space: nowrap;
}

.b-active    { background: #eaf3ea; color: #2b7a2b; }
.b-unlimited { background: #eef; color: #2d6cdf; }
.b-expired   { background: #fbeaea; color: #b23; }
.b-inactive  { background: #eee; color: #777; }

tr.state-inactive td.target a,
tr.state-expired  td.target a { color: var(--muted); text-decoration: line-through; }

button.setexp { background: #eef; color: var(--accent); padding: .35rem .7rem; font-size: .8rem; }
