/* Databáze Viagem — vlastní styl bez frameworku (vychází z portálu / pm) */
* { box-sizing: border-box; }
body {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #f4f5f7;
    color: #1f2733;
}
a { color: #1b6ac9; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.08rem; margin: 0 0 .6rem; }
code, pre, .sql-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .86em; }

/* --- horní lišta --- */
.topbar {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    background: #182236; color: #fff; padding: .55rem 1.2rem;
}
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand span { color: #8fb7f2; }
.brand:hover { text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: .6rem; }
.avatar { width: 26px; height: 26px; border-radius: 50%; }
.avatar-lg { width: 40px; height: 40px; }

.container { max-width: 1180px; margin: 1.2rem auto 3rem; padding: 0 1.2rem; }
.container.wide { max-width: none; }

.crumbs { font-size: .88rem; margin-bottom: .8rem; color: #68738a; display: flex; flex-wrap: wrap; gap: .35rem; }
.crumbs .sep { color: #a3abbb; }

/* --- komponenty --- */
.card {
    background: #fff; border: 1px solid #e3e6eb; border-radius: 10px;
    padding: 1rem 1.2rem; margin-bottom: 1.1rem;
}
.btn {
    display: inline-flex; align-items: center; gap: .45rem;
    background: #fff; border: 1px solid #c6ccd6; border-radius: 8px;
    padding: .42rem .9rem; font: inherit; font-size: .92rem; cursor: pointer; color: #1f2733; white-space: nowrap;
}
.btn:hover { background: #f0f2f5; text-decoration: none; }
.btn-xs { padding: .2rem .55rem; font-size: .82rem; }
.btn-primary { background: #1b6ac9; border-color: #1b6ac9; color: #fff; }
.btn-primary:hover { background: #1558ab; }
.btn-primary .muted { color: #cfe0f7; }
.btn-ghost { background: transparent; border-color: #46536e; color: #cdd6e4; }
.btn-ghost:hover { background: #2a3750; }
.btn-danger { color: #ab1f1f; border-color: #e0b4b4; }
.btn-danger:hover { background: #fbe4e4; }
.btn-google { font-weight: 600; padding: .55rem 1.1rem; }

.flash { border-radius: 8px; padding: .6rem 1rem; margin-bottom: 1rem; }
.flash-ok { background: #e2f4e5; border: 1px solid #9fd8ab; }
.flash-err { background: #fbe4e4; border: 1px solid #eba7a7; }
.flash pre { margin: 0; white-space: pre-wrap; }

.muted { color: #68738a; }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.section-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin: .6rem 0 .8rem; flex-wrap: wrap;
}
.section-head.compact { margin: 0 0 .5rem; }
.section-head h2 { margin: 0; }
.head-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.head-actions form { margin: 0; }

.form-grid { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.form-grid label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; color: #45506a; }
.form-grid .grow { flex: 1 1 220px; }
.form-grid .full { flex: 1 1 100%; }
label.check { flex-direction: row !important; align-items: center; gap: .45rem; display: flex; font-size: .9rem; }
label.inline { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; color: #45506a; white-space: nowrap; }
input[type=text], input[type=email], input[type=search], input[type=date], select, textarea {
    border: 1px solid #c6ccd6; border-radius: 8px; padding: .42rem .6rem;
    font: inherit; font-size: .92rem; background: #fff; width: 100%;
}
label.inline select { width: auto; }
textarea { resize: vertical; }
fieldset { border: 1px dashed #c6ccd6; border-radius: 8px; padding: .6rem .9rem; }
legend { padding: 0 .3rem; font-size: .88rem; color: #45506a; }

/* --- záložky --- */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid #dfe3ea; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .45rem .95rem; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; color: #45506a; }
.tabs a:hover { background: #eef1f6; text-decoration: none; }
.tabs a.active { background: #fff; border-color: #dfe3ea; color: #1f2733; font-weight: 600; margin-bottom: -1px; }

/* --- přehled databází --- */
.conn-title { margin: 1.2rem 0 .6rem; color: #45506a; }
.db-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; }
.db-card {
    background: #fff; border: 1px solid #e3e6eb; border-radius: 12px; padding: 1rem 1.1rem;
    display: flex; flex-direction: column; gap: .3rem; color: inherit;
}
.db-card:hover { border-color: #1b6ac9; text-decoration: none; box-shadow: 0 2px 10px rgba(24, 34, 54, .07); }
.db-name { font-weight: 700; font-size: 1.02rem; }
.empty-state p { margin: .3rem 0; }

/* --- seznamy --- */
table.list { width: 100%; border-collapse: collapse; }
table.list th {
    text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em;
    color: #68738a; padding: .3rem .55rem; border-bottom: 1px solid #e3e6eb; font-weight: 600;
}
table.list td { padding: .45rem .55rem; border-bottom: 1px solid #eef0f3; vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.inactive td { opacity: .55; }
.table-filter { margin-bottom: .7rem; max-width: 420px; }
.user-cell { display: flex; align-items: center; gap: .6rem; color: inherit; }
a.user-cell:hover { text-decoration: none; }
.link-list { margin: 0; padding-left: 1.2rem; }

/* --- badge --- */
.badge {
    display: inline-block; border-radius: 20px; padding: .03rem .55rem; vertical-align: middle;
    font-size: .76rem; font-weight: 600; white-space: nowrap; margin-right: .2rem; background: #e8e9ee; color: #5b6373;
}
.lvl-read { background: #e1edfb; color: #1b5bab; }
.lvl-write { background: #fff1d6; color: #8a5a00; }
.lvl-full { background: #fbe4e4; color: #a01c1c; }
.b-on { background: #e2f4e5; color: #1d7a34; }
.b-off { background: #e8e9ee; color: #5b6373; }
.b-err { background: #fbe4e4; color: #a01c1c; }
.b-role { background: #e1edfb; color: #1b5bab; }
.kind-v, .kind-m { background: #efe6fb; color: #6a3fb0; }
.kind-f { background: #e6f6f6; color: #1d6d6d; }
.act-update, .act-insert { background: #fff1d6; color: #8a5a00; }
.act-delete, .act-sql_error, .act-denied { background: #fbe4e4; color: #a01c1c; }
.act-sql, .act-export { background: #e1edfb; color: #1b5bab; }
.act-admin { background: #efe6fb; color: #6a3fb0; }

/* --- filtry --- */
.filters { padding: .8rem 1rem; }
.filter-top { display: flex; gap: .8rem; align-items: center; margin-bottom: .5rem; }
.filter-top input[type=search] { max-width: 420px; }
.filter-rows { display: flex; flex-direction: column; gap: .4rem; }
.filter-row { display: flex; gap: .4rem; align-items: center; }
.filter-row select { width: auto; max-width: 260px; }
.filter-row input { max-width: 380px; }
.filter-actions { display: flex; gap: .5rem; margin-top: .6rem; align-items: center; }

/* --- datová mřížka --- */
.grid-wrap { overflow: auto; max-height: calc(100vh - 230px); background: #fff; border: 1px solid #e3e6eb; border-radius: 10px; }
table.grid { border-collapse: separate; border-spacing: 0; font-size: .86rem; min-width: 100%; }
table.grid th {
    position: sticky; top: 0; z-index: 1; background: #f7f8fa; text-align: left; font-weight: 600;
    padding: .4rem .6rem; border-bottom: 1px solid #dfe3ea; border-right: 1px solid #eef0f3; white-space: nowrap; vertical-align: bottom;
}
table.grid th a { color: #1f2733; }
.coltype { display: block; font-weight: 400; font-size: .74rem; color: #8a93a6; }
.colcomment { display: block; font-weight: 400; font-size: .78rem; color: #68738a; }
table.grid td {
    padding: .3rem .6rem; border-bottom: 1px solid #eef0f3; border-right: 1px solid #f3f4f7;
    max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top;
}
table.grid tbody tr:hover td { background: #f5f8fd; }
td.rowlink, th.rowlink { width: 1.6rem; text-align: center; padding: .3rem .2rem; position: sticky; left: 0; background: #fff; }
th.rowlink { background: #f7f8fa; z-index: 2; }
td.rowlink a { font-weight: 700; font-size: 1.05rem; display: block; }
.null { color: #a3abbb; font-style: italic; font-size: .85em; }
.empty { color: #a3abbb; font-size: .85em; }
.more { color: #1b6ac9; }
a.fk { border-bottom: 1px dotted #1b6ac9; }
.pager { display: flex; gap: .8rem; align-items: center; justify-content: center; margin: .9rem 0; }

/* --- detail řádku --- */
table.fields { width: 100%; border-collapse: collapse; }
table.fields th {
    text-align: left; vertical-align: top; width: 260px; padding: .55rem .8rem .55rem 0;
    border-bottom: 1px solid #eef0f3; font-weight: 600; font-size: .92rem; word-break: break-word;
}
table.fields td { padding: .45rem 0; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.field { display: flex; gap: .4rem; align-items: flex-start; flex-wrap: wrap; }
.field-mode { width: auto; flex: 0 0 auto; }
.field-value { flex: 1 1 360px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88rem; }
.field-value:disabled { background: #f3f4f7; color: #a3abbb; }
.value { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .88rem; }
.form-actions { display: flex; gap: .8rem; align-items: center; margin-top: .9rem; flex-wrap: wrap; }

/* --- SQL konzole --- */
.sql-input { width: 100%; font-size: .9rem; line-height: 1.45; tab-size: 4; min-height: 160px; }
.sql-pre { white-space: pre-wrap; word-break: break-word; background: #f7f8fa; border-radius: 6px; padding: .6rem .8rem; margin: .4rem 0 0; font-size: .84rem; }
.pg-error { font-size: .86rem; }
.result-status { margin: .3rem 0 .6rem; }
.history summary { cursor: pointer; font-weight: 600; }
.history-list { margin: .6rem 0 0; padding-left: 1.1rem; }
.history-list li { margin-bottom: .3rem; }

/* --- práva --- */
table.grants td { vertical-align: top; }
table.grants select { width: auto; }
tr.grant-row.off td:not(:first-child):not(:nth-child(2)) { opacity: .35; }
.table-picker { margin-top: .4rem; border: 1px dashed #c6ccd6; border-radius: 8px; padding: .5rem .6rem; max-width: 560px; }
.picker-list { max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: .1rem; }
.picker-list .schema { font-weight: 600; margin-top: .3rem; }
.picker-list .tbl { padding-left: 1.3rem; }
.picker-tools { display: flex; gap: .5rem; margin-top: .4rem; align-items: center; }
.picker-tools input { max-width: 240px; }
.accounts .account-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .4rem; }
.account-label { flex: 0 0 110px; font-size: .88rem; color: #45506a; }

table.audit td { font-size: .86rem; }
table.audit details summary { cursor: pointer; }

/* --- login a chyby --- */
.login-box {
    max-width: 400px; margin: 8vh auto; background: #fff; border: 1px solid #e3e6eb;
    border-radius: 12px; padding: 2rem; text-align: center;
    display: flex; flex-direction: column; gap: .9rem; align-items: center;
}
.login-box h1 { font-size: 1.3rem; }
.login-box hr { width: 100%; border: 0; border-top: 1px solid #e3e6eb; }
.dev-login { display: flex; flex-direction: column; gap: .5rem; width: 100%; }
.error-card { max-width: 640px; margin: 6vh auto; }

@media (max-width: 760px) {
    .topbar-name { display: none; }
    table.fields th { width: 120px; }
    .filter-row { flex-wrap: wrap; }
    table.list th:nth-child(n+4), table.list td:nth-child(n+4) { display: none; }
    table.grants th, table.grants td { display: table-cell !important; }
}
